Opt Outs

GET /:account/opt_outs{?q,exact[]}

An OptOut is a phone number that has been flagged to prevent delivery of messages.

The response of this endpoint is a representation of a paginated collection of opt outs. To keep our payloads small, each representation is a condensed version of a stored opt out that is focused on relevant information.

This endpoint is also capable of searching across phone numbers using partial matching (minimum of 3 characters) by using the q parameter.

To search on multiple phone numbers, the exact parameter can be used. This parameter expects an array of phone numbers and will return opt outs for each given phone number, if present.

Examples

List all OptOuts on an Account

Request

GET /my_account/opt_outs
Example
$ curl -i -H Accept:"application/vnd.textus+jsonld" \
    -H Authorization:"Bearer {token}" \
    -X GET /my_account/opt_outs
    

Response

Status

200

Response Type

hydra:Collection

Example Body

{
  "@type": "hydra:Collection",
  "@context": "/contexts/hydra:Collection.jsonld",
  "id": "/my_account/opt_outs",
  "members": [
    {
      "@type": "OptOut",
      "@context": "/contexts/OptOut.jsonld",
      "id": "/textus/opt_outs/+15553031234",
      "createdAt": "2020-07-30T15:18:52.133Z",
      "formattedPhoneNumber": "5553031234",
      "user": null,
      "createdVia": "User",
      "originatingAccount": {
        "@type": "Account",
        "@context": "/contexts/Account.jsonld",
        "id": "/accounts/my_account",
        "name": "My Account"
      }
    }
  ],
  "totalItems": 1,
  "view": {
    "@type": "hydra:PartialCollectionView",
    "@context": "/contexts/hydra:PartialCollectionView.jsonld",
    "id": "/my_account/opt_outs",
    "first": "/my_account/opt_outs",
    "next": null,
    "previous": null
  }
}

Search OptOuts by Phone Number

Request

GET /my_account/opt_outs?q=303
Example
$ curl -i -H Accept:"application/vnd.textus+jsonld" \
    -H Authorization:"Bearer {token}" \
    -X GET /my_account/opt_outs?q=303
    

Response

Status

200

Response Type

hydra:Collection

Example Body

{
  "@type": "hydra:Collection",
  "@context": "/contexts/hydra:Collection.jsonld",
  "id": "/my_account/opt_outs?q=303",
  "members": [
    {
      "@type": "OptOut",
      "@context": "/contexts/OptOut.jsonld",
      "id": "/textus/opt_outs/+15553031234",
      "createdAt": "2020-07-30T15:18:52.133Z",
      "formattedPhoneNumber": "5553031234",
      "user": null,
      "createdVia": "User",
      "originatingAccount": {
        "@type": "Account",
        "@context": "/contexts/Account.jsonld",
        "id": "/accounts/my_account",
        "name": "My Account"
      }
    }
  ],
  "totalItems": 1,
  "view": {
    "@type": "hydra:PartialCollectionView",
    "@context": "/contexts/hydra:PartialCollectionView.jsonld",
    "id": "/my_account/opt_outs?q=303",
    "first": "/my_account/opt_outs?q=303",
    "next": null,
    "previous": null
  }
}

Search OptOuts by Exact Phone Numbers

Request

GET /my_account/opt_outs?exact[]=5553031234&exact[]=%28555%29%20222-1234
Example
$ curl -i -H Accept:"application/vnd.textus+jsonld" \
    -H Authorization:"Bearer {token}" \
    -X GET /my_account/opt_outs?exact[]=5553031234&exact[]=%28555%29%20222-1234
    

Response

Status

200

Response Type

hydra:Collection

Example Body

{
  "@type": "hydra:Collection",
  "@context": "/contexts/hydra:Collection.jsonld",
  "id": "/my_account/opt_outs?exact[]=5553031234&exact[]=5552221234",
  "members": [
    {
      "@type": "OptOut",
      "@context": "/contexts/OptOut.jsonld",
      "id": "/textus/opt_outs/+15553031234",
      "createdAt": "2020-07-30T15:18:52.133Z",
      "formattedPhoneNumber": "5553031234",
      "user": null,
      "createdVia": "User",
      "originatingAccount": {
        "@type": "Account",
        "@context": "/contexts/Account.jsonld",
        "id": "/accounts/my_account",
        "name": "My Account"
      }
    }
  ],
  "totalItems": 1,
  "view": {
    "@type": "hydra:PartialCollectionView",
    "@context": "/contexts/hydra:PartialCollectionView.jsonld",
    "id": "/my_account/opt_outs?exact[]=5553031234&exact[]=5552221234",
    "first": "/my_account/opt_outs?exact[]=5553031234&exact[]=5552221234",
    "next": null,
    "previous": null
  }
}

Table of contents


© 2024 TextUs