Node.js
import { PeriskopeApi } from '@periskope/periskope-client';
const client = new PeriskopeApi({
authToken: 'YOUR_API_KEY',
phone: 'YOUR_PHONE_NUMBER', // e.g., '919876543210'
});
async function updateContact() {
const response = await client.contact.update({
contact_id: '919537851844',
contact_name: 'Periskope test'
});
console.log(response);
}
updateContact();curl -X PATCH \
https://api.periskope.app/v1/contacts/{contact_id} \
-H 'Authorization: Bearer <token>' \
-H 'Content-Type: application/json' \
-H 'x-phone: YOUR_PHONE_NUMBER' \
-d '{
"contact_name": "Periskope test"
}'{
"chat_ids": [
"120363231636311517@g.us",
"120363298090795525@g.us",
"120363300395249001@g.us",
"120363329861739657@g.us",
"120363331984403446@g.us",
"120363346994879209@g.us",
"120363348209472631@g.us",
"120363352652386702@g.us",
"120363363215130488@g.us",
"120363367240230358@g.us",
"120363370646127343@g.us",
"120363371655584481@g.us",
"120363372525172897@g.us",
"120363373761356282@g.us",
"120363378751945209@g.us",
"120363387379991154@g.us",
"120363387670530253@g.us",
"120363388696354849@g.us",
"120363389171465741@g.us",
"120363391093262494@g.us",
"120363392706769636@g.us",
"919537851844@c.us"
],
"contact_color": "#FA6533",
"contact_id": "919537851844@c.us",
"contact_image": "https://storage.googleapis.com/periskope-images/2997dd64-89bf-48d3-9a22-b314fca017e5%2F919537851844%40c.us.jpg?timestamp=1737445692504",
"contact_name": "BK Local1",
"contact_type": "user",
"is_imported": null,
"is_internal": false,
"is_my_contact": null,
"is_wa_contact": false,
"label_ids": {
"label-ukjqhqngnakncalm": true,
"label-wwfrdqogccexahnv": true
},
"labels": [
"label1",
"label2"
],
"org_id": "2997dd64-89bf-48d3-9a22-b314fca017e5",
"updated_at": "2025-01-22T05:41:15.303874+00:00"
}{
"code": "VALIDATION_ERROR",
"fields": {
"contact_name": {
"message": "contact_name is missing"
},
"is_internal": {
"message": "is_internal is missing"
},
"labels": {
"message": "labels is missing"
}
},
"message": "Invalid body. At least one of the following keys are required: contact_name, is_internal, labels",
"name": "Validation Error",
"status": 422
}Contact APIs
Update Contact
This endpoint updates properties of a contact
Node.js
import { PeriskopeApi } from '@periskope/periskope-client';
const client = new PeriskopeApi({
authToken: 'YOUR_API_KEY',
phone: 'YOUR_PHONE_NUMBER', // e.g., '919876543210'
});
async function updateContact() {
const response = await client.contact.update({
contact_id: '919537851844',
contact_name: 'Periskope test'
});
console.log(response);
}
updateContact();curl -X PATCH \
https://api.periskope.app/v1/contacts/{contact_id} \
-H 'Authorization: Bearer <token>' \
-H 'Content-Type: application/json' \
-H 'x-phone: YOUR_PHONE_NUMBER' \
-d '{
"contact_name": "Periskope test"
}'{
"chat_ids": [
"120363231636311517@g.us",
"120363298090795525@g.us",
"120363300395249001@g.us",
"120363329861739657@g.us",
"120363331984403446@g.us",
"120363346994879209@g.us",
"120363348209472631@g.us",
"120363352652386702@g.us",
"120363363215130488@g.us",
"120363367240230358@g.us",
"120363370646127343@g.us",
"120363371655584481@g.us",
"120363372525172897@g.us",
"120363373761356282@g.us",
"120363378751945209@g.us",
"120363387379991154@g.us",
"120363387670530253@g.us",
"120363388696354849@g.us",
"120363389171465741@g.us",
"120363391093262494@g.us",
"120363392706769636@g.us",
"919537851844@c.us"
],
"contact_color": "#FA6533",
"contact_id": "919537851844@c.us",
"contact_image": "https://storage.googleapis.com/periskope-images/2997dd64-89bf-48d3-9a22-b314fca017e5%2F919537851844%40c.us.jpg?timestamp=1737445692504",
"contact_name": "BK Local1",
"contact_type": "user",
"is_imported": null,
"is_internal": false,
"is_my_contact": null,
"is_wa_contact": false,
"label_ids": {
"label-ukjqhqngnakncalm": true,
"label-wwfrdqogccexahnv": true
},
"labels": [
"label1",
"label2"
],
"org_id": "2997dd64-89bf-48d3-9a22-b314fca017e5",
"updated_at": "2025-01-22T05:41:15.303874+00:00"
}{
"code": "VALIDATION_ERROR",
"fields": {
"contact_name": {
"message": "contact_name is missing"
},
"is_internal": {
"message": "is_internal is missing"
},
"labels": {
"message": "labels is missing"
}
},
"message": "Invalid body. At least one of the following keys are required: contact_name, is_internal, labels",
"name": "Validation Error",
"status": 422
}Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Path Parameters
- The unique identifier of the contact
- Must be formatted as
country_code + number(e.g.,918527184400). Do not include special characters
Example:
"919537851844"
Body
application/json
Update the contact name. Note that this name will only be updated on Periskope (not on the phone)
Example:
"BK Local1"
Mark the contact as internal. Messages from internal contacts are not flagged
Example:
false
- A comma-separated list of labels to be assigned to the contacts. All labels are case-insensitive.
- If any label currently does not exist, it will be created
Example:
"label1,label2"
Response
200 OK
The response is a contact object. Refer to the contact object here
Was this page helpful?