Skip to Content
cURL

cURL

Welcome to the ReSMS cURL integration guide.

This guide explains how you can interact with the ReSMS API using simple cURL commands from your terminal or scripts.

Features

  • Send SMS: Send text messages to phone numbers.
  • Send OTP: Generate and send one-time passwords (OTP) for user verification.
  • Verify OTP: Validate OTP codes entered by users.

Setup

First, you need to get an API key on ReSMS Dashboard.

Send SMS

You can send an SMS using a simple POST request:

curl --location 'https://api.resms.dev/sms' \ --header 'x-api-key: re_12345' \ --header 'Content-Type: application/json' \ --data '{ "to": "+33612345678", "message": "Welcome to ReSMS!" }'

Parameters

FieldTypeRequiredDescription
toStringThe phone number of the recipient, in international format (E.164)
messageStringThe SMS content (160 characters max)
senderIdStringThe alphanumeric sender name displayed

Response

Success Response

{ "data": { "messageId": "msg_12345" } }

Error Response

{ "message": "Invalid phone number", "name": "PHONE_NUMBER_PARSING_FAILED" }

Possible errors:

NameMessage
COUNTRY_DETECTION_FAILEDUnable to detect country code from phone number
PHONE_NUMBER_PARSING_FAILEDInvalid phone number
INSUFFICIENT_SMS_QUOTAFailed to update message status
MESSAGE_STATUS_UPDATE_FAILEDFailed to update message status

Send OTP

Here’s how to send an OTP verification code to a phone number:

curl --location 'https://api.resms.dev/otp' \ --header 'x-api-key: re_12345' \ --header 'Content-Type: application/json' \ --data '{ "to": "+33612345678", "message": "Here is your code: {CODE}" }'

Parameters

FieldTypeRequiredDescriptionDefault Value
toStringThe phone number of the recipient, in international format (E.164)
messageStringThe SMS content (160 characters max). It must contain {CODE}.
senderIdStringThe alphanumeric sender name displayed
codeTypeString ("numeric"| "alpha")The type of OTP code to generate"numeric"
codeLengthNumberThe length of the OTP code6
validityMinutesNumberThe validity period of the OTP in minutes.5

Example with all parameters:

curl --location 'https://api.resms.dev/otp' \ --header 'x-api-key: re_12345' \ --header 'Content-Type: application/json' \ --data '{ "to": "+33612345678", "message": "Your verification code is {CODE}. Valid for 10 minutes.", "senderId": "MyApp", "codeType": "numeric", "codeLength": 6, "validityMinutes": 10 }'

Response

Success Response

{ "data": { "phoneNumber": "+33612345678", "expiresAt": "2025-07-20T15:30:00Z" } }

Error Response

{ "message": "Message template must contain {CODE} placeholder", "name": "INVALID_MESSAGE_TEMPLATE" }

Possible errors:

CodeHTTP StatusMessage
INVALID_MESSAGE_TEMPLATE400Message template must contain {CODE} placeholder
INVALID_CODE_LENGTH400Code length must be between 4 and 16
INVALID_VALIDITY_DURATION400Validity duration must be between 1 minute and 1440 minutes (24 hours)
TOO_MANY_OTP_REQUESTS429Too many OTP requests for this phone number

Verify OTP

To verify an OTP code entered by the user:

curl --location 'https://api.resms.dev/otp/verify' \ --header 'x-api-key: re_12345' \ --header 'Content-Type: application/json' \ --data '{ "to": "+33612345678", "code": "123456" }'

Parameters

FieldTypeRequiredDescription
toStringThe phone number the OTP was sent to, in international format (E.164)
codeStringThe verification code entered by the user

Response

Success Response

{ "data": { "otpId": "otp_12345", "phoneNumber": "+33612345678", "verifiedAt": "2025-07-20T15:25:00Z" } }

Error Response

{ "message": "OTP not found", "name": "OTP_NOT_FOUND" }

Possible errors:

CodeHTTP StatusMessage
OTP_NOT_FOUND404OTP not found
OTP_INVALID400OTP is invalid
OTP_EXPIRED400OTP has expired
OTP_ALREADY_VERIFIED400OTP already verified
INVALID_OTP_CODE400Invalid OTP code

Have feedback, found a bug, or want to suggest a feature?

Last updated on