SMS API Reference

One single API to push and pull data from multiple connectors.

10.8.1

Introduction

Welcome to the SMS API.

You can use this API to access all SMS API endpoints.

Base URL

The base URL for all API requests is https://unify.apideck.com

Headers

Custom headers that are expected as part of the request. Note that RFC7230 states header names are case insensitive.

Name Type Required Description
x-apideck-consumer-id String Yes The id of the customer stored inside Apideck Vault. This can be a user id, account id, device id or whatever entity that can have integration within your app.
x-apideck-service-id String No Describe the service you want to call (e.g., pipedrive). Only needed when a customer has activated multiple integrations for the same Unified API.
x-apideck-raw Boolean No Include raw response. Mostly used for debugging purposes.
x-apideck-app-id String Yes The application id of your Unify application. Available at https://app.apideck.com/unify/api-keys.
Authorization String Yes Bearer API KEY

Authorization

You can interact with the API through the authorization methods below.

apiKey

To use API you have to sign up and get your own API key. Unify API accounts have sandbox mode and live mode API keys. To change modes just use the appropriate key to get a live or test object. You can find your API keys on the unify settings of your Apideck app. Your Apideck application_id can also be found on the same page.

Authenticate your API requests by including your test or live secret API key in the request header.

  • Bearer authorization header: Authorization: Bearer "YOUR_API_KEY_HERE"
  • Application id header: x-apideck-app-id: "YOUR_APP_ID_HERE"

You should use the public keys on the SDKs and the secret keys to authenticate API requests.

Do not share or include your secret API keys on client side code. Your API keys carry significant privileges. Please ensure to keep them 100% secure and be sure to not share your secret API keys in areas that are publicly accessible like GitHub.

Learn how to set the Authorization header inside Postman https://learning.postman.com/docs/postman/sending-api-requests/authorization/#api-key

Go to Unify to grab your API KEY https://app.apideck.com/unify/api-keys

Security Scheme Type API Key
Header parameter name Authorization

Pagination

All API resources have support for bulk retrieval via list APIs. Apideck uses cursor-based pagination via the optional cursor and limit parameters.

To fetch the first page of results, call the list API without a cursor parameter. Afterwards you can fetch subsequent pages by providing a cursor parameter. You will find the next cursor in the response body in meta.cursors.next. If meta.cursors.next is null you're at the end of the list.

In the REST API you can also use the links from the response for added convenience. Simply call the URL in links.next to get the next page of results.

Query Parameters

Name Type Required Description
cursor String No Cursor to start from. You can find cursors for next & previous pages in the meta.cursors property of the response.
limit Number No Number of results to return. Minimum 1, Maximum 200, Default 20

Response Body

Name Type Description
meta.cursors.previous String Cursor to navigate to the previous page of results through the API
meta.cursors.current String Cursor to navigate to the current page of results through the API
meta.cursors.next String Cursor to navigate to the next page of results through the API
meta.items_on_page Number Number of items returned in the data property of the response
links.previous String Link to navigate to the previous page of results through the API
links.current String Link to navigate to the current page of results through the API
links.next String Link to navigate to the next page of results through the API

⚠️ meta.cursors.previous/links.previous is not available for all connectors.

SDKs and API Clients

We currently offer a Node.js, PHP, Python and .NET SDK. Need another SDK? Request the SDK of your choice.

Debugging

Because of the nature of the abstraction we do in Apideck Unify we still provide the option to the receive raw requests and responses being handled underlying. By including the raw flag ?raw=true in your requests you can still receive the full request. Please note that this increases the response size and can introduce extra latency.

Errors

The API returns standard HTTP response codes to indicate success or failure of the API requests. For errors, we also return a customized error message inside the JSON response. You can see the returned HTTP status codes below.

Code Title Description
200 OK The request message has been successfully processed, and it has produced a response. The response message varies, depending on the request method and the requested data.
201 Created The request has been fulfilled and has resulted in one or more new resources being created.
204 No Content The server has successfully fulfilled the request and that there is no additional content to send in the response payload body.
400 Bad Request The receiving server cannot understand the request because of malformed syntax. Do not repeat the request without first modifying it; check the request for errors, fix them and then retry the request.
401 Unauthorized The request has not been applied because it lacks valid authentication credentials for the target resource.
402 Payment Required Subscription data is incomplete or out of date. You'll need to provide payment details to continue.
403 Forbidden You do not have the appropriate user rights to access the request. Do not repeat the request.
404 Not Found The origin server did not find a current representation for the target resource or is not willing to disclose that one exists.
409 Conflict The request could not be completed due to a conflict with the current state of the target resource.
422 Unprocessable Entity The server understands the content type of the request entity, and the syntax of the request entity is correct but was unable to process the contained instructions.
429 Too Many Requests You sent too many requests in a given amount of time ("rate limit"). Try again later
5xx Server Errors Something went wrong with the Unify API. These errors are logged on our side. You can contact our team to resolve the issue.

Handling errors

The Unify API and SDKs can produce errors for many reasons, such as a failed requests due to misconfigured integrations, invalid parameters, authentication errors, and network unavailability.

Error Types

RequestValidationError

Request is not valid for the current endpoint. The response body will include details on the validation error. Check the spelling and types of your attributes, and ensure you are not passing data that is outside of the specification.

UnsupportedFiltersError

Filters in the request are valid, but not supported by the connector. Remove the unsupported filter(s) to get a successful response.

UnsupportedSortFieldError

Sort field (sort[by]) in the request is valid, but not supported by the connector. Replace or remove the sort field to get a successful response.

InvalidCursorError

Pagination cursor in the request is not valid for the current connector. Make sure to use a cursor returned from the API, for the same connector.

ConnectorExecutionError

A Unified API request made via one of our downstream connectors returned an unexpected error. The status_code returned is proxied through to error response along with their original response via the error detail.

UnauthorizedError

We were unable to authorize the request as made. This can happen for a number of reasons, from missing header params to passing an incorrect authorization token. Verify your Api Key is being set correctly in the authorization header. ie: Authorization: 'Bearer sk_live_***'

ConnectorCredentialsError

A request using a given connector has not been authorized. Ensure the connector you are trying to use has been configured correctly and been authorized for use.

ConnectorDisabledError

A request has been made to a connector that has since been disabled. This may be temporary - You can contact our team to resolve the issue.

ConnectorRateLimitError

You sent too many request to a connector. These rate limits vary from connector to connector. You will need to try again later.

RequestLimitError

You have reached the number of requests included in your Free Tier Subscription. You will not be able to make further requests until you upgrade your subscription. Please reach out to sales@apideck.com to continue making requests.

EntityNotFoundError

You've made a request for a resource or route that does not exist. Verify your path parameters or any identifiers used to fetch this resource.

OAuthCredentialsNotFoundError

When adding a connector integration that implements OAuth, both a client_id and client_secret must be provided before any authorizations can be performed. Verify the integration has been configured properly before continuing.

IntegrationNotFoundError

The requested connector integration could not be found associated to your application_id. Verify your application_id is correct, and that this connector has been added and configured for your application.

ConnectionNotFoundError

A valid connection could not be found associated to your application_id. Something may have interrupted the authorization flow. You may need to start the connector authorization process again.

ConnectionSettingsError

The connector has required settings that were not supplied. Verify connection.settings contains all required settings for the connector to be callable.

ConnectorNotFoundError

A request was made for an unknown connector. Verify your service_id is spelled correctly, and that this connector is enabled for your provided unified_api.

OAuthRedirectUriError

A request was made either in a connector authorization flow, or attempting to revoke connector access without a valid redirect_uri. This is the url the user should be returned to on completion of process.

OAuthInvalidStateError

The state param is required and is used to ensure the outgoing authorization state has not been altered before the user is redirected back. It also contains required params needed to identify the connector being used. If this has been altered, the authorization will not succeed.

OAuthCodeExchangeError

When attempting to exchange the authorization code for an access_token during an OAuth flow, an error occurred. This may be temporary. You can reattempt authorization or contact our team to resolve the issue.

OAuthConnectorError

It seems something went wrong on the connector side. It's possible this connector is in beta or still under development. We've been notified and are working to fix this issue.

MappingError

There was an error attempting to retrieve the mapping for a given attribute. We've been notified and are working to fix this issue.

ConnectorMappingNotFoundError

It seems the implementation for this connector is incomplete. It's possible this connector is in beta or still under development. We've been notified and are working to fix this issue.

ConnectorResponseMappingNotFoundError

We were unable to retrieve the response mapping for this connector. It's possible this connector is in beta or still under development. We've been notified and are working to fix this issue.

ConnectorOperationMappingNotFoundError

Connector mapping has not been implemented for the requested operation. It's possible this connector is in beta or still under development. We've been notified and are working to fix this issue.

ConnectorWorkflowMappingError

The composite api calls required for this operation have not been mapped entirely. It's possible this connector is in beta or still under development. We've been notified and are working to fix this issue.

ConnectorOperationUnsupportedError

You're attempting a call that is not supported by the connector. It's likely this operation is supported by another connector, but we're unable to implement for this one.

PaginationNotSupportedError

Pagination is not yet supported for this connector, try removing limit and/or cursor from the query. It's possible this connector is in beta or still under development. We've been notified and are working to fix this issue.

API Design

API Styles and data formats

REST API

The API is organized around REST, providing simple and predictable URIs to access and modify objects. Requests support standard HTTP methods like GET, PUT, POST, and DELETE and standard status codes. JSON is returned by all API responses, including errors. In all API requests, you must set the content-type HTTP header to application/json. All API requests must be made over HTTPS. Calls made over HTTP will fail.

Available HTTP methods

The Apideck API uses HTTP verbs to understand if you want to read (GET), delete (DELETE) or create (POST) an object. When your web application cannot do a POST or DELETE, we provide the ability to set the method through the query parameter _method.

POST /messages
GET /messages
GET /messages/{messageId}
PATCH /messages/{messageId}
DELETE /messages/{messageId}

Response bodies are always UTF-8 encoded JSON objects, unless explicitly documented otherwise. For some endpoints and use cases we divert from REST to provide a better developer experience.

Schema

All API requests and response bodies adhere to a common JSON format representing individual items, collections of items, links to related items and additional meta data.

Meta

Meta data can be represented as a top level member named “meta”. Any information may be provided in the meta data. It’s most common use is to return the total number of records when requesting a collection of resources.

Request IDs

Each API request has an associated request identifier. You can find this value in the response headers, under Request-Id. You can also find request identifiers in the URLs of individual request logs in your Dashboard. If you need to contact us about a specific request, providing the request identifier will ensure the fastest possible resolution.

Fixed field types

Dates

The dates returned by the API are all represented in UTC (ISO8601 format).

This example 2019-11-14T00:55:31.820Z is defined by the ISO 8601 standard. The T in the middle separates the year-month-day portion from the hour-minute-second portion. The Z on the end means UTC, that is, an offset-from-UTC of zero hours-minutes-seconds. The Z is pronounced "Zulu" per military/aviation tradition.

The ISO 8601 standard is more modern. The formats are wisely designed to be easy to parse by machine as well as easy to read by humans across cultures.

Prices and Currencies

All prices returned by the API are represented as integer amounts in a currency’s smallest unit. For example, $5 USD would be returned as 500 (i.e, 500 cents).

For zero-decimal currencies, amounts will still be provided as an integer but without the need to divide by 100. For example, an amount of ¥5 (JPY) would be returned as 5.

All currency codes conform to ISO 4217.

Support

If you have problems or need help with your case, you can always reach out to our Support.

Static IP

Some of the APIs you want to use can require a static IP. Apideck's static IP feature allows you to use Apideck with a fixed IP avoiding the need for you to set up your own infrastructure. This feature is currently available to all Apideck customers. To use this feature, the API Vendor will need to whitelist the associated static IP addresses. The provided static IP addresses are fixed to their specified region and shared by all customers who use this feature.

Messages

The Messages model

idstring

A unique identifier for an object.

fromstring
required

The phone number that initiated the message.

tostring
required

The phone number that received the message.

subjectstring
bodystring<= 1600 characters
required

The message text.

typestring
Enum:smsmms

Set to sms for SMS messages and mms for MMS messages.

Messages example
{}

List Messages

get
https://unify.apideck.com/sms/messages

List Messages

Authorizations:

Header parameters

x-apideck-consumer-idstring
required

ID of the consumer which you want to get or push data from

x-apideck-app-idstring
required

The ID of your Unify application

x-apideck-service-idstring

Provide the service id you want to call (e.g., pipedrive). Only needed when a consumer has activated multiple integrations for a Unified API.

Query parameters

rawboolean
Default:false

Include raw response. Mostly used for debugging purposes

cursorstring or null

Cursor to start from. You can find cursors for next/previous pages in the meta.cursors property of the response.

limitinteger[ 1 .. 200 ]
Default:20

Number of results to return. Minimum 1, Maximum 200, Default 20

fieldsstring or null

The 'fields' parameter allows API users to specify the fields they want to include in the API response. If this parameter is not present, the API will return all available fields. If this parameter is present, only the fields specified in the comma-separated string will be included in the response. Nested properties can also be requested by using a dot notation.

Example: fields=name,email,addresses.city

In the example above, the response will only include the fields "name", "email" and "addresses.city". If any other fields are available, they will be excluded.

Responses

200Messages
400Bad Request
401Unauthorized
402Payment Required
404The specified resource was not found
422Unprocessable

Mapping coverage per connector

MessageBird
Plivo
Twilio
Telnyx
Request
Vonage
Request

Request example

Node
import { Apideck } from '@apideck/node'

const apideck = new Apideck({
  apiKey: 'REPLACE_WITH_API_KEY',
  appId: 'REPLACE_WITH_APP_ID',
  consumerId: 'REPLACE_WITH_CONSUMER_ID'
})

try {
  const { data } = await apideck.sms.messagesAll({})
  console.log('API called successfully', data)
} catch (error) {
  console.error(error)
}

Response example

{
  "status_code": 200,
  "status": "OK",
  "service": "twilio",
  "resource": "Messages",
  "operation": "all",
  "data": [
    {
      "id": "12345",
      "from": "+15017122661",
      "to": "+15017122662",
      "subject": "Picture",
      "body": "Hi! How are you doing?",
      "type": "sms",
      "number_of_units": 1,
      "number_of_media_files": 1,
      "direction": "outbound-api",
      "status": "sent",
      "scheduled_at": "2020-09-30T07:43:32.000Z",
      "sent_at": "2020-09-30T07:43:32.000Z",
      "webhook_url": "https://unify.apideck.com/webhook/webhooks/eyz329dkffdl4949/x/sms",
      "reference": "CUST001",
      "price": {
        "per_unit": "0.01",
        "total_amount": "0.01",
        "currency": "USD"
      },
      "error": {
        "code": "X1",
        "message": "Something went wrong"
      },
      "messaging_service_id": "123456",
      "custom_mappings": {},
      "updated_by": "12345",
      "created_by": "12345",
      "updated_at": "2020-09-30T07:43:32.000Z",
      "created_at": "2020-09-30T07:43:32.000Z"
    }
  ],
  "meta": {
    "items_on_page": 50,
    "cursors": {
      "previous": "em9oby1jcm06OnBhZ2U6OjE=",
      "current": "em9oby1jcm06OnBhZ2U6OjI=",
      "next": "em9oby1jcm06OnBhZ2U6OjM="
    }
  },
  "links": {
    "previous": "https://unify.apideck.com/crm/companies?cursor=em9oby1jcm06OnBhZ2U6OjE%3D",
    "current": "https://unify.apideck.com/crm/companies",
    "next": "https://unify.apideck.com/crm/companies?cursor=em9oby1jcm06OnBhZ2U6OjM"
  }
}

Create Message

post
https://unify.apideck.com/sms/messages

Create Message

Authorizations:

Header parameters

x-apideck-consumer-idstring
required

ID of the consumer which you want to get or push data from

x-apideck-app-idstring
required

The ID of your Unify application

x-apideck-service-idstring

Provide the service id you want to call (e.g., pipedrive). Only needed when a consumer has activated multiple integrations for a Unified API.

Query parameters

rawboolean
Default:false

Include raw response. Mostly used for debugging purposes

Request body schema

application/json
fromstring
required

The phone number that initiated the message.

tostring
required

The phone number that received the message.

subjectstring
bodystring<= 1600 characters
required

The message text.

typestring
Enum:smsmms

Set to sms for SMS messages and mms for MMS messages.

scheduled_atstring

The scheduled date and time of the message.

webhook_urlstring

Define a webhook to receive delivery notifications.

referencestring

A client reference.

messaging_service_idstring

The ID of the Messaging Service used with the message. In case of Plivo this links to the Powerpack ID.

pass_throughobjects

The pass_through property allows passing service-specific, custom data or structured modifications in request body when creating or updating resources.

Responses

201Messages
400Bad Request
401Unauthorized
402Payment Required
404The specified resource was not found
422Unprocessable

Mapping coverage per connector

MessageBird
Plivo
Telnyx
Twilio
Vonage

Request example

{
  "from": "+15017122661",
  "to": "+15017122662",
  "subject": "Picture",
  "body": "Hi! How are you doing?",
  "type": "sms",
  "scheduled_at": "2020-09-30T07:43:32.000Z",
  "webhook_url": "https://unify.apideck.com/webhook/webhooks/eyz329dkffdl4949/x/sms",
  "reference": "CUST001",
  "messaging_service_id": "123456",
  "pass_through": [
    {
      "service_id": "string",
      "operation_id": "string",
      "extend_object": {},
      "extend_paths": [
        {
          "path": "$.nested.property",
          "value": {
            "TaxClassificationRef": {
              "value": "EUC-99990201-V1-00020000"
            }
          }
        }
      ]
    }
  ]
}

Response example

{
  "status_code": 200,
  "status": "OK",
  "service": "twilio",
  "resource": "Messages",
  "operation": "add",
  "data": {
    "id": "12345"
  }
}

Get Message

get
https://unify.apideck.com/sms/messages/{id}

Get Message

Authorizations:

Path parameters

idstring
required

ID of the record you are acting upon.

Header parameters

x-apideck-consumer-idstring
required

ID of the consumer which you want to get or push data from

x-apideck-app-idstring
required

The ID of your Unify application

x-apideck-service-idstring

Provide the service id you want to call (e.g., pipedrive). Only needed when a consumer has activated multiple integrations for a Unified API.

Query parameters

rawboolean
Default:false

Include raw response. Mostly used for debugging purposes

fieldsstring or null

The 'fields' parameter allows API users to specify the fields they want to include in the API response. If this parameter is not present, the API will return all available fields. If this parameter is present, only the fields specified in the comma-separated string will be included in the response. Nested properties can also be requested by using a dot notation.

Example: fields=name,email,addresses.city

In the example above, the response will only include the fields "name", "email" and "addresses.city". If any other fields are available, they will be excluded.

Responses

200Messages
400Bad Request
401Unauthorized
402Payment Required
404The specified resource was not found
422Unprocessable

Mapping coverage per connector

MessageBird
Plivo
Telnyx
Twilio
Vonage
Request

Request example

Node
import { Apideck } from '@apideck/node'

const apideck = new Apideck({
  apiKey: 'REPLACE_WITH_API_KEY',
  appId: 'REPLACE_WITH_APP_ID',
  consumerId: 'REPLACE_WITH_CONSUMER_ID'
})

try {
  const { data } = await apideck.sms.messagesOne({
    id: 'id_example'
  })
  console.log('API called successfully', data)
} catch (error) {
  console.error(error)
}

Response example

{
  "status_code": 200,
  "status": "OK",
  "service": "twilio",
  "resource": "Messages",
  "operation": "one",
  "data": {
    "id": "12345",
    "from": "+15017122661",
    "to": "+15017122662",
    "subject": "Picture",
    "body": "Hi! How are you doing?",
    "type": "sms",
    "number_of_units": 1,
    "number_of_media_files": 1,
    "direction": "outbound-api",
    "status": "sent",
    "scheduled_at": "2020-09-30T07:43:32.000Z",
    "sent_at": "2020-09-30T07:43:32.000Z",
    "webhook_url": "https://unify.apideck.com/webhook/webhooks/eyz329dkffdl4949/x/sms",
    "reference": "CUST001",
    "price": {
      "per_unit": "0.01",
      "total_amount": "0.01",
      "currency": "USD"
    },
    "error": {
      "code": "X1",
      "message": "Something went wrong"
    },
    "messaging_service_id": "123456",
    "custom_mappings": {},
    "updated_by": "12345",
    "created_by": "12345",
    "updated_at": "2020-09-30T07:43:32.000Z",
    "created_at": "2020-09-30T07:43:32.000Z"
  }
}

Update Message

patch
https://unify.apideck.com/sms/messages/{id}

Update Message

Authorizations:

Path parameters

idstring
required

ID of the record you are acting upon.

Header parameters

x-apideck-consumer-idstring
required

ID of the consumer which you want to get or push data from

x-apideck-app-idstring
required

The ID of your Unify application

x-apideck-service-idstring

Provide the service id you want to call (e.g., pipedrive). Only needed when a consumer has activated multiple integrations for a Unified API.

Query parameters

rawboolean
Default:false

Include raw response. Mostly used for debugging purposes

Request body schema

application/json
fromstring
required

The phone number that initiated the message.

tostring
required

The phone number that received the message.

subjectstring
bodystring<= 1600 characters
required

The message text.

typestring
Enum:smsmms

Set to sms for SMS messages and mms for MMS messages.

scheduled_atstring

The scheduled date and time of the message.

webhook_urlstring

Define a webhook to receive delivery notifications.

referencestring

A client reference.

messaging_service_idstring

The ID of the Messaging Service used with the message. In case of Plivo this links to the Powerpack ID.

pass_throughobjects

The pass_through property allows passing service-specific, custom data or structured modifications in request body when creating or updating resources.

Responses

200Messages
400Bad Request
401Unauthorized
402Payment Required
404The specified resource was not found
422Unprocessable
MessageBird
Request
Plivo
Request
Telnyx
Request
Twilio
Request
Vonage
Request

Request example

{
  "from": "+15017122661",
  "to": "+15017122662",
  "subject": "Picture",
  "body": "Hi! How are you doing?",
  "type": "sms",
  "scheduled_at": "2020-09-30T07:43:32.000Z",
  "webhook_url": "https://unify.apideck.com/webhook/webhooks/eyz329dkffdl4949/x/sms",
  "reference": "CUST001",
  "messaging_service_id": "123456",
  "pass_through": [
    {
      "service_id": "string",
      "operation_id": "string",
      "extend_object": {},
      "extend_paths": [
        {
          "path": "$.nested.property",
          "value": {
            "TaxClassificationRef": {
              "value": "EUC-99990201-V1-00020000"
            }
          }
        }
      ]
    }
  ]
}

Response example

{
  "status_code": 200,
  "status": "OK",
  "service": "twilio",
  "resource": "Messages",
  "operation": "update",
  "data": {
    "id": "12345"
  }
}

Delete Message

delete
https://unify.apideck.com/sms/messages/{id}

Delete Message

Authorizations:

Path parameters

idstring
required

ID of the record you are acting upon.

Header parameters

x-apideck-consumer-idstring
required

ID of the consumer which you want to get or push data from

x-apideck-app-idstring
required

The ID of your Unify application

x-apideck-service-idstring

Provide the service id you want to call (e.g., pipedrive). Only needed when a consumer has activated multiple integrations for a Unified API.

Query parameters

rawboolean
Default:false

Include raw response. Mostly used for debugging purposes

Responses

200Messages
400Bad Request
401Unauthorized
402Payment Required
404The specified resource was not found
422Unprocessable

Mapping coverage per connector

Twilio
MessageBird
Request
Plivo
Request
Telnyx
Request
Vonage
Request

Request example

Node
import { Apideck } from '@apideck/node'

const apideck = new Apideck({
  apiKey: 'REPLACE_WITH_API_KEY',
  appId: 'REPLACE_WITH_APP_ID',
  consumerId: 'REPLACE_WITH_CONSUMER_ID'
})

try {
  const { data } = await apideck.sms.messagesDelete({
    id: 'id_example'
  })
  console.log('API called successfully', data)
} catch (error) {
  console.error(error)
}

Response example

{
  "status_code": 200,
  "status": "OK",
  "service": "twilio",
  "resource": "Messages",
  "operation": "delete",
  "data": {
    "id": "12345"
  }
}