Update a contact
const url = 'https://app.surveyrock.com/api/v1/contacts/example';const options = { method: 'PATCH', headers: { 'Idempotency-Key': 'example', 'If-Match': 'example', Authorization: 'Bearer <token>', 'Content-Type': 'application/json' }, body: '{"email":"hello@example.com","first_name":"example","last_name":"example","customFields":{}}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request PATCH \ --url https://app.surveyrock.com/api/v1/contacts/example \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --header 'Idempotency-Key: example' \ --header 'If-Match: example' \ --data '{ "email": "hello@example.com", "first_name": "example", "last_name": "example", "customFields": {} }'Requires an If-Match header: the contact’s current ETag, from any read of it (the ETag header, or meta.etag in the body), or * to skip the check. An update whose ETag is stale (the contact was written since) is refused with 412 and changes nothing. A contact’s ETag changes with every write to it, including its custom-field values. The response carries the next ETag.
Authorizations
Section titled “Authorizations”Parameters
Section titled “Parameters”Path Parameters
Section titled “Path Parameters”Header Parameters
Section titled “Header Parameters”1 to 128 characters, chosen by the caller. A retry with the same key and body replays the first response instead of applying the write twice; the same key with a different body is a 409
The contact’s current ETag (from a read), or *
Request Bodyrequired
Section titled “Request Bodyrequired”object
Values keyed by the id of one of the workspace’s custom fields; an id that is not one is a 422
object
Examplegenerated
{ "email": "hello@example.com", "first_name": "example", "last_name": "example", "customFields": {}}Responses
Section titled “Responses”Contact updated
Headers
Section titled “Headers”Example
"element:abc123:1790690123456789"The resource’s current version, as a strong validator. Opaque: send it back unchanged as If-Match. Also returned as meta.etag in the body, for a client that only sees the body.
Contact not found
The ETag in If-Match is stale: the contact was written since
A customFields key is not a custom field of this workspace: each error names the field
If-Match header required