Node.js
import { Rewrite } from '@rewritetoday/sdk';
const rewrite = new Rewrite(process.env.REWRITE_API_KEY!);
const { data, error } = await rewrite.contacts.batch({
contacts: [
{ phone: '+5511999999999', name: 'Fernanda' },
{ phone: '+5511888888888', name: 'Carlos' },
],
upsert: true,
});
if (error) throw error;{
"ok": true,
"data": {
"inserted": 2,
"updated": 0,
"ignored": 0,
"total": 2
}
}Contacts
Create contacts in batch
Create between 1 and 100 contacts in one request. When upsert=true, Rewrite updates matched contacts instead of ignoring them.
POST
/
contacts
/
batch
Node.js
import { Rewrite } from '@rewritetoday/sdk';
const rewrite = new Rewrite(process.env.REWRITE_API_KEY!);
const { data, error } = await rewrite.contacts.batch({
contacts: [
{ phone: '+5511999999999', name: 'Fernanda' },
{ phone: '+5511888888888', name: 'Carlos' },
],
upsert: true,
});
if (error) throw error;{
"ok": true,
"data": {
"inserted": 2,
"updated": 0,
"ignored": 0,
"total": 2
}
}Authorizations
Send your API key as Authorization: Bearer rw_....
Required scope: project:write.
Body
application/json