Subscribe or unsubscribe contacts
const url = 'https://api.sendwing.app/api/organizations/example/mailing-lists/example/contacts';const options = { method: 'POST', headers: {'x-api-key': '<x-api-key>', 'Content-Type': 'application/json'}, body: '{"subscribe":["example"],"unsubscribe":["example"]}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://api.sendwing.app/api/organizations/example/mailing-lists/example/contacts \ --header 'Content-Type: application/json' \ --header 'x-api-key: <x-api-key>' \ --data '{ "subscribe": [ "example" ], "unsubscribe": [ "example" ] }'Subscribes contacts to the list and unsubscribes them, by ID, up to 1000 at a time. Unsubscribing keeps the contact on the list as unsubscribed. A contact already in the state you ask for is left alone. Subscribing is refused, and listed in refused with the reason, for a contact whose own status isn’t subscribed and for one who unsubscribed from this list themselves: only they can subscribe again.
Authorizations
Section titled “Authorizations”Parameters
Section titled “Parameters”Path Parameters
Section titled “Path Parameters”The workspace, like org_…. An OAuth access token works in the one the member picked when connecting, which GET /me returns.
Like list_…
Request Body
Section titled “Request Body”object
Contacts to subscribe, by ID
Contacts to unsubscribe, by ID
Example generated
{ "subscribe": [ "example" ], "unsubscribe": [ "example" ]}Responses
Section titled “Responses”What changed
object
Contacts subscribed by this request
Contacts unsubscribed by this request
Contacts that can’t be subscribed, and why
object
IDs that aren’t contacts in this workspace
Example generated
{ "subscribed": 1, "unsubscribed": 1, "refused": [ { "id": "example", "reason": "example" } ], "notFound": [ "example" ]}The request isn’t valid; issues lists each problem
object
What went wrong, in words you can show people
For a 400: each invalid field, by its path in the request, like events.0.name
object
For a 5xx: quote it when contacting support
Example generated
{ "error": "example", "issues": [ { "path": "example", "message": "example" } ], "requestId": "example"}The API key or access token is missing, invalid or expired
object
What went wrong, in words you can show people
For a 400: each invalid field, by its path in the request, like events.0.name
object
For a 5xx: quote it when contacting support
Example generated
{ "error": "example", "issues": [ { "path": "example", "message": "example" } ], "requestId": "example"}The API key’s permissions, or the app’s scopes and the member’s role, don’t allow this
object
What went wrong, in words you can show people
For a 400: each invalid field, by its path in the request, like events.0.name
object
For a 5xx: quote it when contacting support
Example generated
{ "error": "example", "issues": [ { "path": "example", "message": "example" } ], "requestId": "example"}Not found in this workspace
object
What went wrong, in words you can show people
For a 400: each invalid field, by its path in the request, like events.0.name
object
For a 5xx: quote it when contacting support
Example generated
{ "error": "example", "issues": [ { "path": "example", "message": "example" } ], "requestId": "example"}Too many requests; wait for the seconds in Retry-After
object
What went wrong, in words you can show people
For a 400: each invalid field, by its path in the request, like events.0.name
object
For a 5xx: quote it when contacting support
Example generated
{ "error": "example", "issues": [ { "path": "example", "message": "example" } ], "requestId": "example"}