Skip to content

Opt-Out

Note: The API key provided in the Authorization header must have the apik_ prefix.

Schema

Request

NameTypeDescription
host_numberString(format:e164)The DID associated with the opt-out, in E.164 format excluding the + prefix (eg 17055551234). Can be omitted if the type is account, csp_brand, or csp_campaign.
remote_numberString(format:e164)The recipient phone number associated with the opt-out, in E.164 format excluding the + prefix (eg 17055551234).
keywordStringThe keyword associated with the opt-out.
typeStringThe scope of opt-out. Valid values are:
  • account (all messaging on the account)
  • csp_brand (all messaging on the CSP brand)
  • csp_campaign (all messaging on the CSP campaign)
  • host_did (all messaging on the host DID)
tcr_brand_idStringOptional TCR brand ID associated with the opt-out. Included only when the type is csp_brand.
tcr_campaign_idStringOptional TCR campaign ID associated with the opt-out. Included only when the type is csp_campaign.

Get all Opt-Outs

Request:

GET /api/v1/messaging/optout_items
Authorization: Bearer apik_ABC123

Response:

HTTP/1.1 200 OK
Content-Type: application/json
{
"data": {
"items": [
{
"associations": {
"account": {
"data": {
"id": "string"
},
"type": "account"
},
"csp_brand": {
"data": {
"id": null
},
"type": "csp_brand"
},
"csp_campaign": {
"data": {
"id": null
},
"type": "csp_campaign"
},
"host_did": {
"data": {
"id": null
},
"type": "did"
},
"sms": {
"data": {
"id": null
},
"type": "sms"
}
},
"data": {
"host_number": "string",
"id": "string",
"inserted_at": "2024-06-14T00:00:00.000000Z",
"keyword": "string",
"remote_number": "string",
"tcr_brand_id": null,
"tcr_campaign_id": null,
"type": "string",
"updated_at": "2024-06-14T00:00:00.000000Z"
},
"type": "messaging_optout_item"
}
],
"page_info": {
"after": null,
"before": null,
"limit": 50,
"total": null
}
},
"type": "list"
}

Get Opt-Outs for account

Request:

GET https://api.swift-api.com/api/v1/accounts/{account_id}/messaging/optout_items
Authorization: Bearer apik_ABC123

Response:

HTTP/1.1 200 OK
Content-Type: application/json
{
"data": {
"items": [
{
"associations": {
"account": {
"data": {
"id": "string"
},
"type": "account"
},
"csp_brand": {
"data": {
"id": null
},
"type": "csp_brand"
},
"csp_campaign": {
"data": {
"id": null
},
"type": "csp_campaign"
},
"host_did": {
"data": {
"id": null
},
"type": "did"
},
"sms": {
"data": {
"id": null
},
"type": "sms"
}
},
"data": {
"host_number": "string",
"id": "string",
"inserted_at": "2024-06-14T00:00:00.000000Z",
"keyword": "string",
"remote_number": "string",
"tcr_brand_id": null,
"tcr_campaign_id": null,
"type": "string",
"updated_at": "2024-06-14T00:00:00.000000Z"
},
"type": "messaging_optout_item"
}
],
"page_info": {
"after": null,
"before": null,
"limit": 50,
"total": null
}
},
"type": "list"
}

Get Opt-Out by ID

Request:

GET https://api.swift-api.com/api/v1/messaging/optout_items/{id}
Authorization: Bearer apik_ABC123

Response:

HTTP/1.1 200 OK
Content-Type: application/json
{
"associations": {
"account": {
"data": {
"id": "string"
},
"type": "account"
},
"csp_brand": {
"data": {
"id": null
},
"type": "csp_brand"
},
"csp_campaign": {
"data": {
"id": null
},
"type": "csp_campaign"
},
"host_did": {
"data": {
"id": null
},
"type": "did"
},
"sms": {
"data": {
"id": null
},
"type": "sms"
}
},
"data": {
"host_number": "string",
"id": "string",
"inserted_at": "2024-06-14T00:00:00.000000Z",
"keyword": "string",
"remote_number": "string",
"tcr_brand_id": null,
"tcr_campaign_id": null,
"type": "string",
"updated_at": "2024-06-14T00:00:00.000000Z"
},
"type": "messaging_optout_item"
}

Create Opt-Out

Request:

POST https://api.swift-api.com/api/v1/messaging/optout_items
Authorization: Bearer apik_ABC123
{
"data": {
"host_number": "string",
"keyword": "string",
"remote_number": "string",
"type": "string"
},
}

Response:

HTTP/1.1 201 Created
Content-Type: application/json
{
"associations": {
"account": {
"data": {
"id": "string"
},
"type": "account"
},
"csp_brand": {
"data": {
"id": null
},
"type": "csp_brand"
},
"csp_campaign": {
"data": {
"id": null
},
"type": "csp_campaign"
},
"host_did": {
"data": {
"id": "string"
},
"type": "did"
},
"sms": {
"data": {
"id": null
},
"type": "sms"
}
},
"data": {
"host_number": "string",
"id": "string",
"inserted_at": "2024-06-14T00:00:00.000000Z",
"keyword": "string",
"remote_number": "string",
"tcr_brand_id": null,
"tcr_campaign_id": null,
"type": "string",
"updated_at": "2024-06-14T00:00:00.000000Z"
},
"type": "messaging_optout_item"
}

Create Opt-Out for account

Request:

POST https://api.swift-api.com/api/v1/accounts/{account_id}/messaging/optout_items
Authorization: Bearer apik_ABC123
{
"data": {
"host_number": "string",
"keyword": "string",
"remote_number": "string",
"type": "string"
}
}

Response:

HTTP/1.1 201 Created
Content-Type: application/json
{
"associations": {
"account": {
"data": {
"id": "string"
},
"type": "account"
},
"csp_brand": {
"data": {
"id": null
},
"type": "csp_brand"
},
"csp_campaign": {
"data": {
"id": null
},
"type": "csp_campaign"
},
"host_did": {
"data": {
"id": "string"
},
"type": "did"
},
"sms": {
"data": {
"id": null
},
"type": "sms"
}
},
"data": {
"host_number": "string",
"id": "string",
"inserted_at": "2024-06-14T00:00:00.000000Z",
"keyword": "string",
"remote_number": "string",
"tcr_brand_id": null,
"tcr_campaign_id": null,
"type": "string",
"updated_at": "2024-06-14T00:00:00.000000Z"
},
"type": "messaging_optout_item"
}

Update Opt-Out

Request:

PUT https://api.swift-api.com/api/v1/messaging/optout_items/{id}
Authorization: Bearer apik_ABC123
{
"data": {
"host_number": "string",
"keyword": "string",
"remote_number": "string",
"type": "account"
},
}

Response:

HTTP/1.1 200 OK
Content-Type: application/json
{
"associations": {
"account": {
"data": {
"id": "string"
},
"type": "account"
},
"csp_brand": {
"data": {
"id": null
},
"type": "csp_brand"
},
"csp_campaign": {
"data": {
"id": null
},
"type": "csp_campaign"
},
"host_did": {
"data": {
"id": "string"
},
"type": "did"
},
"sms": {
"data": {
"id": null
},
"type": "sms"
}
},
"data": {
"host_number": "string",
"id": "string",
"inserted_at": "2024-06-14T00:00:00.000000Z",
"keyword": "string",
"remote_number": "string",
"tcr_brand_id": null,
"tcr_campaign_id": null,
"type": "string",
"updated_at": "2024-06-14T00:00:00.000000Z"
},
"type": "messaging_optout_item"
}

Delete Opt-Out

Returns the deleted Opt-Out.

Request:

DELETE https://api.swift-api.com/api/v1/messaging/optout_items/{id}
Authorization: Bearer apik_ABC123

Response:

HTTP/1.1 200 OK
Content-Type: application/json
{
"associations": {
"account": {
"data": {
"id": "string"
},
"type": "account"
},
"csp_brand": {
"data": {
"id": null
},
"type": "csp_brand"
},
"csp_campaign": {
"data": {
"id": null
},
"type": "csp_campaign"
},
"host_did": {
"data": {
"id": "string"
},
"type": "did"
},
"sms": {
"data": {
"id": null
},
"type": "sms"
}
},
"data": {
"host_number": "string",
"id": "string",
"inserted_at": "2024-06-14T00:00:00.000000Z",
"keyword": "string",
"remote_number": "string",
"tcr_brand_id": null,
"tcr_campaign_id": null,
"type": "string",
"updated_at": "2024-06-14T00:00:00.000000Z"
},
"type": "messaging_optout_item"
}