Contacts
Create a contact
POST
/{phone_number_id}/contacts
package main
import ( "fmt" "strings" "net/http" "io")
func main() {
url := "https://api.kirim.chat/v1/106540352242922/contacts"
payload := strings.NewReader("{ \"phone_number\": \"example\", \"name\": \"example\", \"email\": \"[email protected]\", \"metadata\": { \"additionalProperty\": \"example\" } }")
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(res) fmt.Println(string(body))
}const url = 'https://api.kirim.chat/v1/106540352242922/contacts';const options = { method: 'POST', headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'}, body: '{"phone_number":"example","name":"example","email":"[email protected]","metadata":{"additionalProperty":"example"}}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}use serde_json::json;use reqwest;
#[tokio::main]pub async fn main() { let url = "https://api.kirim.chat/v1/106540352242922/contacts";
let payload = json!({ "phone_number": "example", "name": "example", "metadata": json!({"additionalProperty": "example"}) });
let mut headers = reqwest::header::HeaderMap::new(); headers.insert("Authorization", "Bearer <token>".parse().unwrap()); headers.insert("Content-Type", "application/json".parse().unwrap());
let client = reqwest::Client::new(); let response = client.post(url) .headers(headers) .json(&payload) .send() .await;
let results = response.unwrap() .json::<serde_json::Value>() .await .unwrap();
dbg!(results);}curl --request POST \ --url https://api.kirim.chat/v1/106540352242922/contacts \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --data '{ "phone_number": "example", "name": "example", "email": "[email protected]", "metadata": { "additionalProperty": "example" } }'Create a contact attached to the WhatsApp account identified by phone_number_id in the URL path.
Authorizations
Section titled “Authorizations ”Parameters
Section titled “ Parameters ”Path Parameters
Section titled “Path Parameters ” phone_number_id
required
Meta WhatsApp Business phone_number_id of the connected account that should send / own this resource. Discoverable via GET /v1/accounts (returned as phone_number_id on each row).
string
Example
106540352242922Request Body
Section titled “Request Body ” Media type application/json
object
phone_number
required
string
name
string
email
string | null format: email
metadata
object
key
additional properties
Example generated
{ "phone_number": "example", "name": "example", "metadata": { "additionalProperty": "example" }}Responses
Section titled “ Responses ”Contact created
Media type application/json
object
data
required
object
id
required
string
object
required
string
phone_number
required
string | null
name
required
string | null
email
required
string | null
metadata
required
object | null
whatsapp_account
required
object
phone_number
required
string | null
created_at
required
string format: date-time
updated_at
required
string format: date-time
request_id
required
string
Example
{ "data": { "id": "ctc_01HXYZABCDEFGHJKMNPQRSTVWX", "object": "contact" }}Validation failure
Media type application/json
object
error
required
object
type
required
string
code
required
string
message
required
string
param
string
request_id
required
string
Example
{ "error": { "type": "invalid_request_error", "code": "invalid_phone_number", "request_id": "req_01HXYZABCDEFGHJKMNPQRSTVWX" }}Authentication failure
Media type application/json
object
error
required
object
type
required
string
code
required
string
message
required
string
param
string
request_id
required
string
Example
{ "error": { "type": "invalid_request_error", "code": "invalid_phone_number", "request_id": "req_01HXYZABCDEFGHJKMNPQRSTVWX" }}Resource not found
Media type application/json
object
error
required
object
type
required
string
code
required
string
message
required
string
param
string
request_id
required
string
Example
{ "error": { "type": "invalid_request_error", "code": "invalid_phone_number", "request_id": "req_01HXYZABCDEFGHJKMNPQRSTVWX" }}Semantic failure (e.g. idempotency key reuse)
Media type application/json
object
error
required
object
type
required
string
code
required
string
message
required
string
param
string
request_id
required
string
Example
{ "error": { "type": "invalid_request_error", "code": "invalid_phone_number", "request_id": "req_01HXYZABCDEFGHJKMNPQRSTVWX" }}Rate limit exceeded
Media type application/json
object
error
required
object
type
required
string
code
required
string
message
required
string
param
string
request_id
required
string
Example
{ "error": { "type": "invalid_request_error", "code": "invalid_phone_number", "request_id": "req_01HXYZABCDEFGHJKMNPQRSTVWX" }}Internal server error
Media type application/json
object
error
required
object
type
required
string
code
required
string
message
required
string
param
string
request_id
required
string
Example
{ "error": { "type": "invalid_request_error", "code": "invalid_phone_number", "request_id": "req_01HXYZABCDEFGHJKMNPQRSTVWX" }}