Skip to main content
POST
/
customers
Create a customer
curl --request POST \
  --url https://api.togai.com/customers \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "id": "01BX5ZZKBKACTAV9WEVGEMMVRZ",
  "name": "ACME Enterprise",
  "primaryEmail": "admin@example.com",
  "address": {
    "phoneNumber": "+919876543210",
    "line1": "2281 Broadway Street",
    "line2": "G-31",
    "postalCode": "29501",
    "city": "Florence",
    "state": "South Carolina",
    "country": "US"
  },
  "settings": [
    {
      "id": "customerSettingId",
      "value": "INR",
      "namespace": "USER",
      "name": "Settings Name",
      "dataType": "STRING"
    }
  ],
  "account": {
    "id": "ACC00001",
    "name": "Primary Account",
    "invoiceCurrency": "USD",
    "aliases": [
      "acme_primary",
      "admin@example.com"
    ],
    "settings": [
      {
        "id": "accountSettingId",
        "value": "INR",
        "namespace": "USER",
        "name": "Settings Name",
        "dataType": "STRING"
      }
    ]
  }
}
'
import requests

url = "https://api.togai.com/customers"

payload = {
"id": "01BX5ZZKBKACTAV9WEVGEMMVRZ",
"name": "ACME Enterprise",
"primaryEmail": "admin@example.com",
"address": {
"phoneNumber": "+919876543210",
"line1": "2281 Broadway Street",
"line2": "G-31",
"postalCode": "29501",
"city": "Florence",
"state": "South Carolina",
"country": "US"
},
"settings": [
{
"id": "customerSettingId",
"value": "INR",
"namespace": "USER",
"name": "Settings Name",
"dataType": "STRING"
}
],
"account": {
"id": "ACC00001",
"name": "Primary Account",
"invoiceCurrency": "USD",
"aliases": ["acme_primary", "admin@example.com"],
"settings": [
{
"id": "accountSettingId",
"value": "INR",
"namespace": "USER",
"name": "Settings Name",
"dataType": "STRING"
}
]
}
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
id: '01BX5ZZKBKACTAV9WEVGEMMVRZ',
name: 'ACME Enterprise',
primaryEmail: 'admin@example.com',
address: {
phoneNumber: '+919876543210',
line1: '2281 Broadway Street',
line2: 'G-31',
postalCode: '29501',
city: 'Florence',
state: 'South Carolina',
country: 'US'
},
settings: [
{
id: 'customerSettingId',
value: 'INR',
namespace: 'USER',
name: 'Settings Name',
dataType: 'STRING'
}
],
account: {
id: 'ACC00001',
name: 'Primary Account',
invoiceCurrency: 'USD',
aliases: ['acme_primary', 'admin@example.com'],
settings: [
{
id: 'accountSettingId',
value: 'INR',
namespace: 'USER',
name: 'Settings Name',
dataType: 'STRING'
}
]
}
})
};

fetch('https://api.togai.com/customers', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));
<?php

$curl = curl_init();

curl_setopt_array($curl, [
CURLOPT_URL => "https://api.togai.com/customers",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'id' => '01BX5ZZKBKACTAV9WEVGEMMVRZ',
'name' => 'ACME Enterprise',
'primaryEmail' => 'admin@example.com',
'address' => [
'phoneNumber' => '+919876543210',
'line1' => '2281 Broadway Street',
'line2' => 'G-31',
'postalCode' => '29501',
'city' => 'Florence',
'state' => 'South Carolina',
'country' => 'US'
],
'settings' => [
[
'id' => 'customerSettingId',
'value' => 'INR',
'namespace' => 'USER',
'name' => 'Settings Name',
'dataType' => 'STRING'
]
],
'account' => [
'id' => 'ACC00001',
'name' => 'Primary Account',
'invoiceCurrency' => 'USD',
'aliases' => [
'acme_primary',
'admin@example.com'
],
'settings' => [
[
'id' => 'accountSettingId',
'value' => 'INR',
'namespace' => 'USER',
'name' => 'Settings Name',
'dataType' => 'STRING'
]
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
package main

import (
"fmt"
"strings"
"net/http"
"io"
)

func main() {

url := "https://api.togai.com/customers"

payload := strings.NewReader("{\n \"id\": \"01BX5ZZKBKACTAV9WEVGEMMVRZ\",\n \"name\": \"ACME Enterprise\",\n \"primaryEmail\": \"admin@example.com\",\n \"address\": {\n \"phoneNumber\": \"+919876543210\",\n \"line1\": \"2281 Broadway Street\",\n \"line2\": \"G-31\",\n \"postalCode\": \"29501\",\n \"city\": \"Florence\",\n \"state\": \"South Carolina\",\n \"country\": \"US\"\n },\n \"settings\": [\n {\n \"id\": \"customerSettingId\",\n \"value\": \"INR\",\n \"namespace\": \"USER\",\n \"name\": \"Settings Name\",\n \"dataType\": \"STRING\"\n }\n ],\n \"account\": {\n \"id\": \"ACC00001\",\n \"name\": \"Primary Account\",\n \"invoiceCurrency\": \"USD\",\n \"aliases\": [\n \"acme_primary\",\n \"admin@example.com\"\n ],\n \"settings\": [\n {\n \"id\": \"accountSettingId\",\n \"value\": \"INR\",\n \"namespace\": \"USER\",\n \"name\": \"Settings Name\",\n \"dataType\": \"STRING\"\n }\n ]\n }\n}")

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

req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")

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

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

fmt.Println(string(body))

}
HttpResponse<String> response = Unirest.post("https://api.togai.com/customers")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"id\": \"01BX5ZZKBKACTAV9WEVGEMMVRZ\",\n \"name\": \"ACME Enterprise\",\n \"primaryEmail\": \"admin@example.com\",\n \"address\": {\n \"phoneNumber\": \"+919876543210\",\n \"line1\": \"2281 Broadway Street\",\n \"line2\": \"G-31\",\n \"postalCode\": \"29501\",\n \"city\": \"Florence\",\n \"state\": \"South Carolina\",\n \"country\": \"US\"\n },\n \"settings\": [\n {\n \"id\": \"customerSettingId\",\n \"value\": \"INR\",\n \"namespace\": \"USER\",\n \"name\": \"Settings Name\",\n \"dataType\": \"STRING\"\n }\n ],\n \"account\": {\n \"id\": \"ACC00001\",\n \"name\": \"Primary Account\",\n \"invoiceCurrency\": \"USD\",\n \"aliases\": [\n \"acme_primary\",\n \"admin@example.com\"\n ],\n \"settings\": [\n {\n \"id\": \"accountSettingId\",\n \"value\": \"INR\",\n \"namespace\": \"USER\",\n \"name\": \"Settings Name\",\n \"dataType\": \"STRING\"\n }\n ]\n }\n}")
.asString();
require 'uri'
require 'net/http'

url = URI("https://api.togai.com/customers")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"id\": \"01BX5ZZKBKACTAV9WEVGEMMVRZ\",\n \"name\": \"ACME Enterprise\",\n \"primaryEmail\": \"admin@example.com\",\n \"address\": {\n \"phoneNumber\": \"+919876543210\",\n \"line1\": \"2281 Broadway Street\",\n \"line2\": \"G-31\",\n \"postalCode\": \"29501\",\n \"city\": \"Florence\",\n \"state\": \"South Carolina\",\n \"country\": \"US\"\n },\n \"settings\": [\n {\n \"id\": \"customerSettingId\",\n \"value\": \"INR\",\n \"namespace\": \"USER\",\n \"name\": \"Settings Name\",\n \"dataType\": \"STRING\"\n }\n ],\n \"account\": {\n \"id\": \"ACC00001\",\n \"name\": \"Primary Account\",\n \"invoiceCurrency\": \"USD\",\n \"aliases\": [\n \"acme_primary\",\n \"admin@example.com\"\n ],\n \"settings\": [\n {\n \"id\": \"accountSettingId\",\n \"value\": \"INR\",\n \"namespace\": \"USER\",\n \"name\": \"Settings Name\",\n \"dataType\": \"STRING\"\n }\n ]\n }\n}"

response = http.request(request)
puts response.read_body
{
  "id": "01BX5ZZKBKACTAV9WEVGEMMVRZ",
  "togaiCustomerId": "customer.dsvvre314.dcs314",
  "name": "ACME Enterprise",
  "primaryEmail": "admin@example.com",
  "address": {
    "phoneNumber": "+919876543210",
    "line1": "2281 Broadway Street",
    "line2": "G-31",
    "postalCode": "29501",
    "city": "Florence",
    "state": "South Carolina",
    "country": "US"
  },
  "settings": [
    {
      "id": "customerSettingId",
      "value": "INR",
      "namespace": "USER",
      "name": "Settings Name",
      "dataType": "STRING"
    }
  ],
  "account": {
    "id": "G234DZZKBKACATFFGVGEMERFH",
    "togaiAccountId": "account.safdla.c234ds",
    "customerId": "01BX5ZZKBKACTAV9WEVGEMMVRZ",
    "togaiCustomerId": "customer.savass.11e1a",
    "name": "ACME Enterprise - Account",
    "invoiceCurrency": "USD",
    "status": "ACTIVE",
    "aliases": [
      {
        "alias": "G234DZZKBKACATFFGVGEMERFH",
        "status": "ACTIVE"
      }
    ],
    "settings": [
      {
        "id": "accountSettingId",
        "value": "INR",
        "namespace": "USER",
        "name": "Settings Name",
        "dataType": "STRING"
      }
    ]
  }
}
{
"message": "<Reason message>"
}
{
"message": "<Reason message>"
}
{
"message": "<Reason message>"
}
{
"message": "<Reason message>"
}
{
"message": "<Reason message>"
}
{
"message": "<Reason message>"
}

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Body

application/json

Payload to create customer

Payload to create customer

id
string
required

Customer identifier

Maximum string length: 50
Example:

"01BX5ZZKBKACTAV9WEVGEMMVRZ"

name
string
required

Name of the Customer

Required string length: 3 - 255
Example:

"ACME Enterprise"

primaryEmail
string
required

Primary email of the customer

Maximum string length: 320
Example:

"admin@example.com"

address
object
required

billing address of the customer

settings
object[]
Maximum array length: 10
account
object

Payload to create account

Response

Response for Create customer request

id
string
required

Identifier of customer

Maximum string length: 50
togaiCustomerId
string
required

Unique identifier of customer

name
string
required

Name of the Customer

Required string length: 3 - 255
primaryEmail
string
required

Primary email of the customer

Maximum string length: 320
billingAddress
string
address
object

billing address of the customer

settings
object[]
Maximum array length: 10
account
object

Structure of an account