Skip to main content
PATCH
/
contacts
/
{id}
JavaScript
import Surge from '@surgeapi/node';

const client = new Surge({
  apiKey: process.env['SURGE_API_KEY'], // This is the default and can be omitted
});

const contact = await client.contacts.update('ctc_01j9dy8mdzfn3r0e8x1tbdrdrf', {
  phone_number: '+18015551234',
});

console.log(contact.id);
import os
from surge import Surge

client = Surge(
api_key=os.environ.get("SURGE_API_KEY"), # This is the default and can be omitted
)
contact = client.contacts.update(
id="ctc_01j9dy8mdzfn3r0e8x1tbdrdrf",
phone_number="+18015551234",
)
print(contact.id)
package main

import (
"context"
"fmt"

"github.com/stainless-sdks/surge-go"
"github.com/stainless-sdks/surge-go/option"
)

func main() {
client := surge.NewClient(
option.WithAPIKey("My API Key"),
)
contact, err := client.Contacts.Update(
context.TODO(),
"ctc_01j9dy8mdzfn3r0e8x1tbdrdrf",
surge.ContactUpdateParams{
PhoneNumber: "+18015551234",
},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", contact.ID)
}
require "surge_api"

surge = SurgeAPI::Client.new(api_key: "My API Key")

contact = surge.contacts.update("ctc_01j9dy8mdzfn3r0e8x1tbdrdrf", phone_number: "+18015551234")

puts(contact)
<?php

require_once dirname(__DIR__) . '/vendor/autoload.php';

use Surge\Client;
use Surge\Core\Exceptions\APIException;

$client = new Client(apiKey: getenv('SURGE_API_KEY') ?: 'My API Key');

try {
$contact = $client->contacts->update(
'ctc_01j9dy8mdzfn3r0e8x1tbdrdrf',
phoneNumber: '+18015551234',
email: 'dom@toretto.family',
firstName: 'Dominic',
lastName: 'Toretto',
metadata: ['car' => '1970 Dodge Charger R/T'],
);

var_dump($contact);
} catch (APIException $e) {
echo $e->getMessage();
}
curl --request PATCH \
--url https://api.surge.app/contacts/{id} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"email": "dom@toretto.family",
"first_name": "Dominic",
"last_name": "Toretto",
"metadata": {
"car": "1970 Dodge Charger R/T"
},
"phone_number": "+18015551234"
}
'
HttpResponse<String> response = Unirest.patch("https://api.surge.app/contacts/{id}")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"email\": \"dom@toretto.family\",\n \"first_name\": \"Dominic\",\n \"last_name\": \"Toretto\",\n \"metadata\": {\n \"car\": \"1970 Dodge Charger R/T\"\n },\n \"phone_number\": \"+18015551234\"\n}")
.asString();
{
  "email": "dom@toretto.family",
  "first_name": "Dominic",
  "id": "ctc_01j9dy8mdzfn3r0e8x1tbdrdrf",
  "last_name": "Toretto",
  "metadata": {
    "car": "1970 Dodge Charger R/T"
  },
  "phone_number": "+18015551234"
}
{
"error": {
"message": "The requested resource could not be found.",
"type": "not_found"
}
}

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Path Parameters

id
string
required

The ID of the contact to update.

Example:

"ctc_01j9dy8mdzfn3r0e8x1tbdrdrf"

Body

application/json

Parameters for creating a contact

phone_number
string<phone-number>
required

The contact's phone number in E.164 format.

Pattern: ^\+[1-9]\d{6,14}$
Example:

"+18015551234"

email
string<email>

The contact's email address.

first_name
string

The contact's first name.

last_name
string

The contact's last name.

metadata
Metadata · object

Set of key-value pairs that will be stored with the object.

Response

Updated contact

A contact who has consented to receive messages

id
string
required

Unique identifier for the object.

phone_number
string<phone-number>
required

The contact's phone number in E.164 format.

Pattern: ^\+[1-9]\d{6,14}$
Example:

"+18015551234"

email
string<email>

The contact's email address.

first_name
string

The contact's first name.

last_name
string

The contact's last name.

metadata
Metadata · object

Set of key-value pairs that will be stored with the object.