Create Contact

POST https://api.yonoma.io/v1/contacts/{group_id}/create

Send POST request to this end point to create a new contact.

Request
Path Params

group_id string required

The ID of the group

Body Params (application/json) Example

email string required

The contact's email address

status string required

The contact's status

message string required

Description of the success message

phone string

The contact's phone number

gender string

The contact's gender

address string

The contact's address

city string

The contact's city

state string

The contact's state

country string

The contact's country

zipcode string

The contact's zipcode


{
    "email"  :  "[email protected]", 
    "status"  :  "Subscribed", 
    "data"  :  {
        "phone"  :  "1234567890",
        "gender"  :  "Male",
        "address"  :  "123, NY street",
        "city"  :  "NY City",
        "state"  :  "NY",
        "country"  :  "US",
        "zipcode"  :  "10001"
    }
}

Code Samples

const myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
myHeaders.append("Authorization", "Bearer YOUR_API_KEY");

const raw = JSON.stringify({
  "email": "[email protected]",
  "status": "Subscribed",
  "data": {
    "phone": "1234567890",
    "gender": "Male",
    "address": "123, NY street",
    "city": "NY City",
    "state": "NY",
    "country": "US",
    "zipcode": "10001"
  }
});

const requestOptions = {
  method: "POST",
  headers: myHeaders,
  body: raw,
  redirect: "follow"
};

fetch("https://api.yonoma.io/v1/contacts/WVVW19L1Z6/create", requestOptions)
  .then((response) => response.text())
  .then((result) => console.log(result))
  .catch((error) => console.error(error));


const axios = require('axios');
let data = JSON.stringify({
  "email": "[email protected]",
  "status": "Subscribed",
  "data": {
    "phone": "1234567890",
    "gender": "Male",
    "address": "123, NY street",
    "city": "NY City",
    "state": "NY",
    "country": "US",
    "zipcode": "10001"
  }
});

let config = {
  method: 'post',
  maxBodyLength: Infinity,
  url: 'https://api.yonoma.io/v1/contacts/WVVW19L1Z6/create',
  headers: { 
    'Content-Type': 'application/json', 
    'Authorization': 'Bearer YOUR_API_KEY'
  },
  data : data
};

axios.request(config)
.then((response) => {
  console.log(JSON.stringify(response.data));
})
.catch((error) => {
  console.log(error);
});


var settings = {
  "url": "https://api.yonoma.io/v1/contacts/WVVW19L1Z6/create",
  "method": "POST",
  "timeout": 0,
  "headers": {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_API_KEY"
  },
  "data": JSON.stringify({
    "email": "[email protected]",
    "status": "Subscribed",
    "data": {
      "phone": "1234567890",
      "gender": "Male",
      "address": "123, NY street",
      "city": "NY City",
      "state": "NY",
      "country": "US",
      "zipcode": "10001"
    }
  }),
};

$.ajax(settings).done(function (response) {
  console.log(response);
});


var data = JSON.stringify({
  "email": "[email protected]",
  "status": "Subscribed",
  "data": {
    "phone": "1234567890",
    "gender": "Male",
    "address": "123, NY street",
    "city": "NY City",
    "state": "NY",
    "country": "US",
    "zipcode": "10001"
  }
});

var xhr = new XMLHttpRequest();

xhr.addEventListener("readystatechange", function() {
  if(this.readyState === 4) {
    console.log(this.responseText);
  }
});

xhr.open("POST", "https://api.yonoma.io/v1/contacts/WVVW19L1Z6/create");
xhr.setRequestHeader("Content-Type", "application/json");
xhr.setRequestHeader("Authorization", "Bearer YOUR_API_KEY");

xhr.send(data);


var https = require('follow-redirects').https;
var fs = require('fs');

var options = {
  'method': 'POST',
  'hostname': 'api.yonoma.io',
  'path': '/v1/contacts/WVVW19L1Z6/create',
  'headers': {
    'Content-Type': 'application/json',
    'Authorization': 'Bearer YOUR_API_KEY'
  },
  'maxRedirects': 20
};

var req = https.request(options, function (res) {
  var chunks = [];

  res.on("data", function (chunk) {
    chunks.push(chunk);
  });

  res.on("end", function (chunk) {
    var body = Buffer.concat(chunks);
    console.log(body.toString());
  });

  res.on("error", function (error) {
    console.error(error);
  });
});

var postData = JSON.stringify({
  "email": "[email protected]",
  "status": "Subscribed",
  "data": {
    "phone": "1234567890",
    "gender": "Male",
    "address": "123, NY street",
    "city": "NY City",
    "state": "NY",
    "country": "US",
    "zipcode": "10001"
  }
});

req.write(postData);

req.end();


var request = require('request');
var options = {
  'method': 'POST',
  'url': 'https://api.yonoma.io/v1/contacts/WVVW19L1Z6/create',
  'headers': {
    'Content-Type': 'application/json',
    'Authorization': 'Bearer YOUR_API_KEY'
  },
  body: JSON.stringify({
    "email": "[email protected]",
    "status": "Subscribed",
    "data": {
      "phone": "1234567890",
      "gender": "Male",
      "address": "123, NY street",
      "city": "NY City",
      "state": "NY",
      "country": "US",
      "zipcode": "10001"
    }
  })

};
request(options, function (error, response) {
  if (error) throw new Error(error);
  console.log(response.body);
});


var unirest = require('unirest');
var req = unirest('POST', 'https://api.yonoma.io/v1/contacts/WVVW19L1Z6/create')
  .headers({
    'Content-Type': 'application/json',
    'Authorization': 'Bearer YOUR_API_KEY'
  })
  .send(JSON.stringify({
    "email": "[email protected]",
    "status": "Subscribed",
    "data": {
      "phone": "1234567890",
      "gender": "Male",
      "address": "123, NY street",
      "city": "NY City",
      "state": "NY",
      "country": "US",
      "zipcode": "10001"
    }
  }))
  .end(function (res) { 
    if (res.error) throw new Error(res.error); 
    console.log(res.raw_body);
  });

Copy

OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\r\n    \"email\"  :  \"[email protected]\", \r\n    \"status\"  :  \"Subscribed\", \r\n    \"data\"  :  {\r\n        \"phone\"  :  \"1234567890\",\r\n        \"gender\"  :  \"Male\",\r\n        \"address\"  :  \"123, NY street\",\r\n        \"city\"  :  \"NY City\",\r\n        \"state\"  :  \"NY\",\r\n        \"country\"  :  \"US\",\r\n        \"zipcode\"  :  \"10001\"\r\n    }\r\n}");
Request request = new Request.Builder()
  .url("https://api.yonoma.io/v1/contacts/WVVW19L1Z6/create")
  .method("POST", body)
  .addHeader("Content-Type", "application/json")
  .addHeader("Authorization", "Bearer YOUR_API_KEY")
  .build();
Response response = client.newCall(request).execute();


Unirest.setTimeouts(0, 0);
HttpResponse response = Unirest.post("https://api.yonoma.io/v1/contacts/WVVW19L1Z6/create")
  .header("Content-Type", "application/json")
  .header("Authorization", "Bearer YOUR_API_KEY")
  .body("{\r\n    \"email\"  :  \"[email protected]\", \r\n    \"status\"  :  \"Subscribed\", \r\n    \"data\"  :  {\r\n        \"phone\"  :  \"1234567890\",\r\n        \"gender\"  :  \"Male\",\r\n        \"address\"  :  \"123, NY street\",\r\n        \"city\"  :  \"NY City\",\r\n        \"state\"  :  \"NY\",\r\n        \"country\"  :  \"US\",\r\n        \"zipcode\"  :  \"10001\"\r\n    }\r\n}")
  .asString();


package main

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

func main() {

  url := "https://api.yonoma.io/v1/contacts/WVVW19L1Z6/create"
  method := "POST"

  payload := strings.NewReader(`{
    "email"  :  "[email protected]",
    "status"  :  "Subscribed",
    "data"  :  {
        "phone"  :  "1234567890",
        "gender"  :  "Male",
        "address"  :  "123, NY street",
        "city"  :  "NY City",
        "state"  :  "NY",
        "country"  :  "US",
        "zipcode"  :  "10001"
    }
}`)

  client := &http.Client {
  }
  req, err := http.NewRequest(method, url, payload)

  if err != nil {
    fmt.Println(err)
    return
  }
  req.Header.Add("Content-Type", "application/json")
  req.Header.Add("Authorization", "Bearer YOUR_API_KEY")

  res, err := client.Do(req)
  if err != nil {
    fmt.Println(err)
    return
  }
  defer res.Body.Close()

  body, err := ioutil.ReadAll(res.Body)
  if err != nil {
    fmt.Println(err)
    return
  }
  fmt.Println(string(body))
}


$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://api.yonoma.io/v1/contacts/WVVW19L1Z6/create',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS =>'{
    "email"  :  "[email protected]", 
    "status"  :  "Subscribed", 
    "data"  :  {
        "phone"  :  "1234567890",
        "gender"  :  "Male",
        "address"  :  "123, NY street",
        "city"  :  "NY City",
        "state"  :  "NY",
        "country"  :  "US",
        "zipcode"  :  "10001"
    }
}',
  CURLOPT_HTTPHEADER => array(
    'Content-Type: application/json',
    'Authorization: Bearer YOUR_API_KEY'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;


$client = new Client();
$headers = [
  'Content-Type' => 'application/json',
  'Authorization' => 'Bearer YOUR_API_KEY'
];
$body = '{
  "email": "[email protected]",
  "status": "Subscribed",
  "data": {
    "phone": "1234567890",
    "gender": "Male",
    "address": "123, NY street",
    "city": "NY City",
    "state": "NY",
    "country": "US",
    "zipcode": "10001"
  }
}';
$request = new Request('POST', 'https://api.yonoma.io/v1/contacts/WVVW19L1Z6/create', $headers, $body);
$res = $client->sendAsync($request)->wait();
echo $res->getBody();


import http.client
import json

conn = http.client.HTTPSConnection("api.yonoma.io")
payload = json.dumps({
  "email": "[email protected]",
  "status": "Subscribed",
  "data": {
    "phone": "1234567890",
    "gender": "Male",
    "address": "123, NY street",
    "city": "NY City",
    "state": "NY",
    "country": "US",
    "zipcode": "10001"
  }
})
headers = {
  'Content-Type': 'application/json',
  'Authorization': 'Bearer YOUR_API_KEY'
}
conn.request("POST", "/v1/contacts/WVVW19L1Z6/create", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))


import requests
import json

url = "https://api.yonoma.io/v1/contacts/WVVW19L1Z6/create"

payload = json.dumps({
  "email": "[email protected]",
  "status": "Subscribed",
  "data": {
    "phone": "1234567890",
    "gender": "Male",
    "address": "123, NY street",
    "city": "NY City",
    "state": "NY",
    "country": "US",
    "zipcode": "10001"
  }
})
headers = {
  'Content-Type': 'application/json',
  'Authorization': 'Bearer YOUR_API_KEY'
}

response = requests.request("POST", url, headers=headers, data=payload)

print(response.text)


require "uri"
require "json"
require "net/http"

url = URI("https://api.yonoma.io/v1/contacts/WVVW19L1Z6/create")

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

request = Net::HTTP::Post.new(url)
request["Content-Type"] = "application/json"
request["Authorization"] = "Bearer YOUR_API_KEY"
request.body = JSON.dump({
  "email": "[email protected]",
  "status": "Subscribed",
  "data": {
    "phone": "1234567890",
    "gender": "Male",
    "address": "123, NY street",
    "city": "NY City",
    "state": "NY",
    "country": "US",
    "zipcode": "10001"
  }
})

response = https.request(request)
puts response.read_body

Responses
HTTP Code : 200 Content Type : JSON
Data Schema Example

statusCode string required

HTTP status code

status string required

Success status

message string required

Description of the success message

data object optional

contact_id string

The ID of the contact

email string

The contact's email address

status string

The contact's status


{
    "statusCode":200,
    "status": "Success",
    "message": "Contact successfully created!",
    "data": {
        "contact_id": "0UM603V3ME",
        "email": "[email protected]",
        "status": "Subscribed"
    }
}

HTTP Code : 400 Content Type : JSON
Data Schema Example

statusCode string required

HTTP status code

status string required

Error status

message string required

Description of the error message

data object required

phone string

The contact's phone number

gender string

The contact's gender

address string

The contact's address

city string

The contact's city

state string

The contact's state

country string

The contact's country

zipcode string

The contact's zipcode


{
    "statusCode": 400,
    "status": "Error",
    "message": "Email already exist!",
    "data": {
        "email": "[email protected]",
        "status": "Subscribed",
        "data": {
            "phone": "1234567890",
            "gender": "Male",
            "address": "123, NY street",
            "city": "NY City",
            "state": "NY",
            "country": "US",
            "zipcode": "10001"
        }
    }
}

HTTP Code : 401 Content Type : JSON
Data Schema Example

statusCode string required

HTTP status code

status string required

Error status

message string required

Description of the error message

data object required

phone string

The contact's phone number

gender string

The contact's gender

address string

The contact's address

city string

The contact's city

state string

The contact's state

country string

The contact's country

zipcode string

The contact's zipcode


{
    "statusCode": 401,
    "status": "Error",
    "message": "Please send valid apikey in header!",
    "data": {
        "email": "[email protected]",
        "status": "Subscribed",
        "data": {
            "phone": "1234567890",
            "gender": "Male",
            "address": "123, NY street",
            "city": "NY City",
            "state": "NY",
            "country": "US",
            "zipcode": "10001"
        }
    }
}

HTTP Code : 500 Content Type : JSON
Data Schema Example

statusCode string required

HTTP status code

status string required

Error status

message string required

Description of the error message

data object required

phone string

The contact's phone number

gender string

The contact's gender

address string

The contact's address

city string

The contact's city

state string

The contact's state

country string

The contact's country

zipcode string

The contact's zipcode


{
    "statusCode": 500,
    "status": "Error",
    "message": "Sorry! Something went wrong.",
    "data": {
        "email": "[email protected]",
        "status": "Subscribed",
        "data": {
            "phone": "1234567890",
            "gender": "Male",
            "address": "123, NY street",
            "city": "NY City",
            "state": "NY",
            "country": "US",
            "zipcode": "10001"
        }
    }
}

Too many requests hit the API too quickly.