Skip to content

Create customer device

Post
bash
https://api.bunce.so/v1/customers/{customer_id}/devices

Creates customer devices.

If successful, your response includes a copy of the new device(s) entity in an array.

Request

Path Parameter string<uuid> required

id string<uuid> required
Identifier of the customer entity to work with.

Body Parameters required

devices array<{ device_type: string; device_token: string; }> nullableCustomer's devices
bash
curl --request POST \
  --url https://api.bunce.so/v1/customers/0000/devices \
  --header 'X-Authorization: sk_live_************************' \
  --header 'Content-Type: application/json' \
  --data '{
    "devices" : [
        {
            "device_type": "android",
            "device_token": "874jwejfoiowef5974594"
        },
        {
            "device_type": "ios",
            "device_token": "112bbwe348u9839845945675464"
        }
    ]
  }'
go
import (
    "fmt"
    "net/http"
    "io/ioutil"
    "strings"
)

url := "https://api.bunce.so/v1/customers/0000/devices"

payload := strings.NewReader(`{
    "devices" : [
        {
            "device_type": "android",
            "device_token": "874jwejfoiowef5974594"
        },
        {
            "device_type": "ios",
            "device_token": "112bbwe348u9839845945675464"
        }
    ]
}`)

req, _ := http.NewRequest("POST", url, payload)

req.Header.Add("X-Authorization", "sk_live_************************")
req.Header.Add("Content-Type", "application/json")

res, _ := http.DefaultClient.Do(req)

defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)

fmt.Println(res)
fmt.Println(string(body))
js
import  from 'node-fetch'

let  = 'https://api.bunce.so/v1/customers/0000/devices'

let  = {
  : [
    {
      : 'android',
      : '874jwejfoiowef5974594',
    },
    {
      : 'ios',
      : '112bbwe348u9839845945675464',
    },
  ],
}

let  = {
  : 'POST',
  : {
    'X-Authorization': 'sk_live_************************',
    'Content-Type': 'application/json',
  },
  : .(),
}

(, )
  .then(() => .json())
  .then(() => .())
  .catch(() => .('error:' + ))
php
<?php

$client = new http\Client;
$request = new http\Client\Request;

$request->setRequestUrl('https://api.bunce.so/v1/customers/0000/devices');
$request->setRequestMethod('POST');
$request->setHeaders([
  'X-Authorization' => 'sk_live_************************',
  'Content-Type' => 'application/json'
]);

$payload = json_encode([
  "devices" => [
    [
      "device_type" => "android",
      "device_token" => "874jwejfoiowef5974594"
    ],
    [
      "device_type" => "ios",
      "device_token" => "112bbwe348u9839845945675464"
    ]
  ]
]);

$request->setBody(new http\Message\Body($payload));

$client->enqueue($request)->send();
$response = $client->getResponse();

echo $response->getBody();
java
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;

String payload = """
{
  "devices": [
    {
      "device_type": "android",
      "device_token": "874jwejfoiowef5974594"
    },
    {
      "device_type": "ios",
      "device_token": "112bbwe348u9839845945675464"
    }
  ]
}
""";

HttpRequest request = HttpRequest.newBuilder()
    .uri(URI.create("https://api.bunce.so/v1/customers/0000/devices"))
    .header("X-Authorization", "sk_live_************************")
    .header("Content-Type", "application/json")
    .POST(HttpRequest.BodyPublishers.ofString(payload))
    .build();

HttpResponse<String> response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());

Response

json
{
  "success": true,
  "data": [
    {
      "device_id": "9d500063-5ec1-4e77-a269-6369c34d14dd",
      "device_type": "android",
      "token": "874jwejfoiowef5974594",
      "created_at": "2024-10-23T07:41:34.000000Z"
    },
    {
      "device_id": "9d500063-6014-440e-97bd-90b4a62eb0f2",
      "device_type": "ios",
      "token": "112bbwe348u9839845945675464",
      "created_at": "2024-10-23T07:41:34.000000Z"
    }
  ],
  "message": "Customer device created successfully"
}