Node.js SDK
import Migma from 'migma';
const migma = new Migma('YOUR_API_KEY');
const { data, error } = await migma.contacts.update('CONTACT_ID', {
firstName: 'John',
lastName: 'Smith',
projectId: 'PROJECT_ID'
});curl --request PATCH \
--url https://api.migma.ai/v1/contacts/{id} \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"projectId": "<string>",
"firstName": "<string>",
"lastName": "<string>",
"phone": "<string>",
"country": "<string>",
"language": "<string>",
"tags": [
"<string>"
],
"customFields": {}
}
'import requests
url = "https://api.migma.ai/v1/contacts/{id}"
payload = {
"projectId": "<string>",
"firstName": "<string>",
"lastName": "<string>",
"phone": "<string>",
"country": "<string>",
"language": "<string>",
"tags": ["<string>"],
"customFields": {}
}
headers = {
"Authorization": "<api-key>",
"Content-Type": "application/json"
}
response = requests.patch(url, json=payload, headers=headers)
print(response.text)<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.migma.ai/v1/contacts/{id}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PATCH",
CURLOPT_POSTFIELDS => json_encode([
'projectId' => '<string>',
'firstName' => '<string>',
'lastName' => '<string>',
'phone' => '<string>',
'country' => '<string>',
'language' => '<string>',
'tags' => [
'<string>'
],
'customFields' => [
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: <api-key>",
"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.migma.ai/v1/contacts/{id}"
payload := strings.NewReader("{\n \"projectId\": \"<string>\",\n \"firstName\": \"<string>\",\n \"lastName\": \"<string>\",\n \"phone\": \"<string>\",\n \"country\": \"<string>\",\n \"language\": \"<string>\",\n \"tags\": [\n \"<string>\"\n ],\n \"customFields\": {}\n}")
req, _ := http.NewRequest("PATCH", url, payload)
req.Header.Add("Authorization", "<api-key>")
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.patch("https://api.migma.ai/v1/contacts/{id}")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"projectId\": \"<string>\",\n \"firstName\": \"<string>\",\n \"lastName\": \"<string>\",\n \"phone\": \"<string>\",\n \"country\": \"<string>\",\n \"language\": \"<string>\",\n \"tags\": [\n \"<string>\"\n ],\n \"customFields\": {}\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.migma.ai/v1/contacts/{id}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Patch.new(url)
request["Authorization"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"projectId\": \"<string>\",\n \"firstName\": \"<string>\",\n \"lastName\": \"<string>\",\n \"phone\": \"<string>\",\n \"country\": \"<string>\",\n \"language\": \"<string>\",\n \"tags\": [\n \"<string>\"\n ],\n \"customFields\": {}\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"data": {
"id": "<string>",
"email": "jsmith@example.com",
"firstName": "<string>",
"lastName": "<string>",
"phone": "<string>",
"country": "<string>",
"language": "<string>",
"tags": [
"<string>"
],
"customFields": {},
"createdAt": "2023-11-07T05:31:56Z",
"updatedAt": "2023-11-07T05:31:56Z"
},
"error": "<string>"
}{
"success": false,
"error": "<string>",
"code": "<string>",
"data": {}
}{
"success": false,
"error": "<string>",
"code": "<string>",
"data": {}
}{
"success": false,
"error": "<string>",
"code": "<string>",
"data": {}
}Update Contact
Update a contact’s details. Requires API key with audience:write.
PATCH
/
v1
/
contacts
/
{id}
Node.js SDK
import Migma from 'migma';
const migma = new Migma('YOUR_API_KEY');
const { data, error } = await migma.contacts.update('CONTACT_ID', {
firstName: 'John',
lastName: 'Smith',
projectId: 'PROJECT_ID'
});curl --request PATCH \
--url https://api.migma.ai/v1/contacts/{id} \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"projectId": "<string>",
"firstName": "<string>",
"lastName": "<string>",
"phone": "<string>",
"country": "<string>",
"language": "<string>",
"tags": [
"<string>"
],
"customFields": {}
}
'import requests
url = "https://api.migma.ai/v1/contacts/{id}"
payload = {
"projectId": "<string>",
"firstName": "<string>",
"lastName": "<string>",
"phone": "<string>",
"country": "<string>",
"language": "<string>",
"tags": ["<string>"],
"customFields": {}
}
headers = {
"Authorization": "<api-key>",
"Content-Type": "application/json"
}
response = requests.patch(url, json=payload, headers=headers)
print(response.text)<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.migma.ai/v1/contacts/{id}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PATCH",
CURLOPT_POSTFIELDS => json_encode([
'projectId' => '<string>',
'firstName' => '<string>',
'lastName' => '<string>',
'phone' => '<string>',
'country' => '<string>',
'language' => '<string>',
'tags' => [
'<string>'
],
'customFields' => [
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: <api-key>",
"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.migma.ai/v1/contacts/{id}"
payload := strings.NewReader("{\n \"projectId\": \"<string>\",\n \"firstName\": \"<string>\",\n \"lastName\": \"<string>\",\n \"phone\": \"<string>\",\n \"country\": \"<string>\",\n \"language\": \"<string>\",\n \"tags\": [\n \"<string>\"\n ],\n \"customFields\": {}\n}")
req, _ := http.NewRequest("PATCH", url, payload)
req.Header.Add("Authorization", "<api-key>")
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.patch("https://api.migma.ai/v1/contacts/{id}")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"projectId\": \"<string>\",\n \"firstName\": \"<string>\",\n \"lastName\": \"<string>\",\n \"phone\": \"<string>\",\n \"country\": \"<string>\",\n \"language\": \"<string>\",\n \"tags\": [\n \"<string>\"\n ],\n \"customFields\": {}\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.migma.ai/v1/contacts/{id}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Patch.new(url)
request["Authorization"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"projectId\": \"<string>\",\n \"firstName\": \"<string>\",\n \"lastName\": \"<string>\",\n \"phone\": \"<string>\",\n \"country\": \"<string>\",\n \"language\": \"<string>\",\n \"tags\": [\n \"<string>\"\n ],\n \"customFields\": {}\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"data": {
"id": "<string>",
"email": "jsmith@example.com",
"firstName": "<string>",
"lastName": "<string>",
"phone": "<string>",
"country": "<string>",
"language": "<string>",
"tags": [
"<string>"
],
"customFields": {},
"createdAt": "2023-11-07T05:31:56Z",
"updatedAt": "2023-11-07T05:31:56Z"
},
"error": "<string>"
}{
"success": false,
"error": "<string>",
"code": "<string>",
"data": {}
}{
"success": false,
"error": "<string>",
"code": "<string>",
"data": {}
}{
"success": false,
"error": "<string>",
"code": "<string>",
"data": {}
}Authorizations
API key authentication. Use 'Authorization: Bearer YOUR_API_KEY' where YOUR_API_KEY is obtained from the Migma dashboard under Settings → Developers → API Keys.
Path Parameters
Contact ID (MongoDB ObjectId)
Pattern:
^[0-9a-fA-F]{24}$Body
application/json
Phone number (free-form, max 30 chars). Null clears the field.
Maximum string length:
30ISO 3166-1 alpha-2 country code
Language code (ISO 639-1 or BCP 47)
Tag names (tags will be auto-created if they don't exist)
Merged into the contact's existing custom fields — fields you don't include are left untouched. Pass an empty object to clear all custom fields.
Available options:
subscribed, unsubscribed, bounced, non-subscribed Was this page helpful?
⌘I