...
Info |
---|
We strongly suggest using a GraphQL client library in the language of your choice when interacting with the Volt GraphQL API. Using a GraphQL client library will make it easier to take advantage of static typing, API schema introspection, and other features that let you quickly and reliably build into the Volt GraphQL API. For more information, check out What is a GraphQL client and why would I use one?. |
\uD83D\uDCD8 Instructions
First, ensure that you have access to the data necessary for utilizing the Volt GraphQL API:
Have your Volt GraphQL API access token readily available. If you are unsure of where to locate your API token, contact api@textvolt.com.
To send an SMS message using the GraphQL API, you will need to specify the sending and receiving phone numbers, the message content, and a publicly accessible URL for media (if sending MMS).
Note |
---|
A phone number can only be sent from if it belongs to your organization. If you are unsure of which phone numbers belong to your organization, log in to Volt or contact api@textvolt.com. To ensure that phone numbers can be processed correctly by Volt, ensure that any phone numbers are formatted according to the E.164 standard. For example: |
Next, use the necessary data to send a message using the GraphQL API. For example, if you want to send an SMS message with the sending number +15555550123
and the receiving number +15555550145
, construct a GraphQL API request:
Set the
Authorization
header to the valueBearer <token>
, replacing<token>
with the API access token belonging to your organization.Construct a GraphQL query using the
createMessage
mutation:Code Block language graphql mutation createMessage ($to: String!, $from: String!, $body: String!, $media: [String!]) { createMessage (to: $to, from: $from, body: $body, media: $media) { id legacyId toNumber fromNumber status statusDescription media body sentAt confirmedAt } }
Construct a JSON object containing the GraphQL variables for the query created in the previous step:
Code Block language json { "to": "+15555550145", "from": "+15555550123", "body": "Your One Time Code is 654312\n\nReply STOP to opt-out.", "media": [] }
Note: to send an MMS message, set the
media
variable to a list of publicly-accessible media URLs corresponding to the media you wish to send. Supported file types are: JPEG, PNG, GIF, VCF (vCard).Send a
POST
request tohttps://api.respondflow.com/graphql
with the GraphQL query and variables in the request body. We recommend using a GraphQL client library in the language of your choice to construct and send GraphQL API requests.
For example, to send the above GraphQL request using curl:Code Block language bash curl --location --request POST 'https://api.respondflow.com/graphql' \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --data-raw '{"query":"mutation createMessage ($to: String!, $from: String!, $body: String!, $media: [String!]) {\n createMessage (to: $to, from: $from, body: $body, media: $media) {\n id\n legacyId\n toNumber\n fromNumber\n status\n statusDescription\n media\n body\n sentAt\n confirmedAt\n }\n}","variables":{"to":"+15555550145","from":"+15555550123","body":"Your One Time Code is 654312\n\nReply STOP to opt-out.","media":[]}}'
\uD83D\uDCCB Related articles
...
Code Block | ||
---|---|---|
| ||
require "uri" require "net/http" url = URI("https://api.respondflow.com/graphql") https = Net::HTTP.new(url.host, url.port) https.use_ssl = true request = Net::HTTP::Post.new(url) request["Authorization"] = "Bearer <token>" request["Content-Type"] = "application/json" request.body = "{\"query\":\"mutation createMessage ($to: String!, $from: String!, $body: String!, $media: [String!]) {\\n createMessage (to: $to, from: $from, body: $body, media: $media) {\\n id\\n legacyId\\n toNumber\\n fromNumber\\n status\\n statusDescription\\n media\\n body\\n sentAt\\n confirmedAt\\n }\\n}\",\"variables\":{\"to\":\"+15555550145\",\"from\":\"+15555550123\",\"body\":\"Your One Time Code is 654312\\n\\nReply STOP to opt-out.\",\"media\":[]}}" response = https.request(request) puts response.read_body |
Unix shell (curl)
Code Block | ||
---|---|---|
| ||
curl --location --request POST 'https://api.respondflow.com/graphql' \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data-raw '{"query":"mutation createMessage ($to: String!, $from: String!, $body: String!, $media: [String!]) {\n createMessage (to: $to, from: $from, body: $body, media: $media) {\n id\n legacyId\n toNumber\n fromNumber\n status\n statusDescription\n media\n body\n sentAt\n confirmedAt\n }\n}","variables":{"to":"+15555550145","from":"+15555550123","body":"Your One Time Code is 654312\n\nReply STOP to opt-out.","media":[]}}' |