Add records to a suppression list
const url = 'https://api.postlever.com/v1/suppression-lists/497f6eca-6276-4993-bfeb-53cbbbba6f08/records';const options = { method: 'POST', headers: {Authorization: '<Authorization>', 'Content-Type': 'application/json'}, body: '{"records":["test@email.com","other@email.com"]}'};
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.postlever.com/v1/suppression-lists/497f6eca-6276-4993-bfeb-53cbbbba6f08/records \ --header 'Authorization: <Authorization>' \ --header 'Content-Type: application/json' \ --data '{ "records": [ "test@email.com", "other@email.com" ] }'Adds records to one of your suppression lists. A single request accepts up to 1000 records.
Each record must match the list’s format: an email address for a
plain text list, an MD5 hex digest for an md5 list, or a SHA-512 hex
digest for a sha512 list. Values are trimmed and lowercased before they
are stored.
If any record does not match the format, the request is rejected with
400 invalid_request_error and no records are added. detail gives the
zero-based indexes of the records that failed, and errors points at the
first of them.
Records already on the list are counted in duplicateCount instead of
being added again, so sending the same batch twice is safe. Records
repeated within a single request are counted the same way.
Every request is recorded in the list’s import history, alongside manual
uploads. A list takes one import at a time, so a request made while a file
upload or another add-records request is still running is rejected with
409 operation_in_progress.
Authorizations
Section titled “Authorizations”Parameters
Section titled “Parameters”Path Parameters
Section titled “Path Parameters”The id of the suppression list.
Request Bodyrequired
Section titled “Request Bodyrequired”object
The records to add. Each entry must match the suppression list’s
format: an email address for a plain text list, an MD5 hex digest
for an md5 list, or a SHA-512 hex digest for a sha512 list.
Entries must be unique within the request.
Responses
Section titled “Responses”A count of the records added and the records already present.
object
The id of the import recorded for this request, as it appears in the list’s import history.
The number of records in the request.
The number of records added to the list.
The number of records that were already on the list, or repeated
within the request. addedCount plus duplicateCount always equals
totalCount.
Example
{ "importId": "8f14e45f-ea8f-4b1a-9c2d-2b0a5a1f3c7e", "totalCount": 2, "addedCount": 1, "duplicateCount": 1}A record does not match the list’s format, or the request body fails validation.
Error envelope returned by every v1 endpoint for failures, following RFC 9457
Problem Details with code and errors extensions.
object
URI identifying the problem type; dereferences to its documentation.
HTTP status code applicable to this problem.
Short, human-readable summary of the problem type.
Detailed explanation specific to this occurrence.
Error code identifying the specific error condition.
URI reference identifying this specific occurrence (the request URI).
Provides additional information when the error relates to specific request fields.
object
Detailed explanation for this specific field error.
JSON Pointer (RFC 6901) to the request body value that caused the error (e.g. /email, /attributes/firstName).
The URI query parameter that caused the error (e.g. pageSize, name[invalid]).
Examples
A record does not match the list's format
{ "type": "https://docs.postlever.com/error-codes#invalid_request_error", "status": 400, "title": "Invalid request", "detail": "Expected every record to be a valid email address (list format: plain text). Invalid at index(es): 2", "code": "invalid_request_error", "instance": "/v1/suppression-lists/497f6eca-6276-4993-bfeb-53cbbbba6f08/records", "errors": [ { "detail": "Expected every record to be a valid email address (list format: plain text). Invalid at index(es): 2", "pointer": "/records/2" } ]}The request contains more than 1000 records
{ "type": "https://docs.postlever.com/error-codes#invalid_request_error", "status": 400, "title": "Invalid request", "detail": "records must contain no more than 1000 elements", "code": "invalid_request_error", "instance": "/v1/suppression-lists/497f6eca-6276-4993-bfeb-53cbbbba6f08/records", "errors": [ { "detail": "records must contain no more than 1000 elements" } ]}Missing or invalid API key.
Error envelope returned by every v1 endpoint for failures, following RFC 9457
Problem Details with code and errors extensions.
object
URI identifying the problem type; dereferences to its documentation.
HTTP status code applicable to this problem.
Short, human-readable summary of the problem type.
Detailed explanation specific to this occurrence.
Error code identifying the specific error condition.
URI reference identifying this specific occurrence (the request URI).
Provides additional information when the error relates to specific request fields.
object
Detailed explanation for this specific field error.
JSON Pointer (RFC 6901) to the request body value that caused the error (e.g. /email, /attributes/firstName).
The URI query parameter that caused the error (e.g. pageSize, name[invalid]).
Example
{ "type": "https://docs.postlever.com/error-codes#authentication_error", "status": 401, "title": "Authentication failed", "detail": "Missing or invalid API key", "code": "authentication_error", "instance": "/v1/contacts"}Permission denied.
Error envelope returned by every v1 endpoint for failures, following RFC 9457
Problem Details with code and errors extensions.
object
URI identifying the problem type; dereferences to its documentation.
HTTP status code applicable to this problem.
Short, human-readable summary of the problem type.
Detailed explanation specific to this occurrence.
Error code identifying the specific error condition.
URI reference identifying this specific occurrence (the request URI).
Provides additional information when the error relates to specific request fields.
object
Detailed explanation for this specific field error.
JSON Pointer (RFC 6901) to the request body value that caused the error (e.g. /email, /attributes/firstName).
The URI query parameter that caused the error (e.g. pageSize, name[invalid]).
Example
{ "type": "https://docs.postlever.com/error-codes#permission_error", "status": 403, "title": "Permission denied", "detail": "api key required", "code": "permission_error", "instance": "/v1/contacts"}No suppression list with this id exists in your account.
Error envelope returned by every v1 endpoint for failures, following RFC 9457
Problem Details with code and errors extensions.
object
URI identifying the problem type; dereferences to its documentation.
HTTP status code applicable to this problem.
Short, human-readable summary of the problem type.
Detailed explanation specific to this occurrence.
Error code identifying the specific error condition.
URI reference identifying this specific occurrence (the request URI).
Provides additional information when the error relates to specific request fields.
object
Detailed explanation for this specific field error.
JSON Pointer (RFC 6901) to the request body value that caused the error (e.g. /email, /attributes/firstName).
The URI query parameter that caused the error (e.g. pageSize, name[invalid]).
Example
{ "type": "https://docs.postlever.com/error-codes#not_found_error", "status": 404, "title": "Not found", "detail": "Suppression list not found", "code": "not_found_error", "instance": "/v1/suppression-lists/497f6eca-6276-4993-bfeb-53cbbbba6f08/records"}An import is already in flight for this suppression list — a file upload, or another
add-records request (code: operation_in_progress). A list takes one import at a time so
each run’s counts describe only its own records. Retry after the number of seconds given in
the Retry-After header.
Error envelope returned by every v1 endpoint for failures, following RFC 9457
Problem Details with code and errors extensions.
object
URI identifying the problem type; dereferences to its documentation.
HTTP status code applicable to this problem.
Short, human-readable summary of the problem type.
Detailed explanation specific to this occurrence.
Error code identifying the specific error condition.
URI reference identifying this specific occurrence (the request URI).
Provides additional information when the error relates to specific request fields.
object
Detailed explanation for this specific field error.
JSON Pointer (RFC 6901) to the request body value that caused the error (e.g. /email, /attributes/firstName).
The URI query parameter that caused the error (e.g. pageSize, name[invalid]).
Example
{ "type": "https://docs.postlever.com/error-codes#operation_in_progress", "status": 409, "title": "Conflict", "detail": "An import is already in progress for this suppression list, retry later", "code": "operation_in_progress", "instance": "/v1/suppression-lists/497f6eca-6276-4993-bfeb-53cbbbba6f08/records"}Headers
Section titled “Headers”Seconds to wait before retrying.