Guides

Your first SMS with curl and Node

From API key to your first send: the full call with curl, the same one in Node 22 with no dependencies, and how to read status, parts and price in the response.

First things first: the API key

Credentials live inside an app: from the Apps section of the dashboard create one (say "backend-production") and copy the gsms_… key at creation time — it is shown exactly once. If you lose it, you generate a new one.

The key goes in the Authorization header as a Bearer token, on every request. Treat it like a password: never in client-side code, never in a repository.

The request with curl

A transactional SMS needs one POST with three fields: the recipient in international format (+39…), the text and the sender type. The Idempotency-Key header is not mandatory, but add it from day one: it makes retries safe (there is a dedicated guide).

curl

curl -X POST https://sms-jet.com/api/v1/sms/transactional \
  -H "Authorization: Bearer gsms_…" \
  -H "Idempotency-Key: order-1042" \
  -H "Content-Type: application/json" \
  -d '{
    "to": "+393331234567",
    "text": "Your verification code is 123456",
    "sender_type": "system"
  }'

The same call in Node

Node 22 ships native fetch: nothing to install. The call is identical, only the syntax changes:

Node 22

// Node 22 — native fetch, no dependencies
const response = await fetch('https://sms-jet.com/api/v1/sms/transactional', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer gsms_…',
    'Idempotency-Key': 'order-1042',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    to: '+393331234567',
    text: 'Your verification code is 123456',
    sender_type: 'system',
  }),
})

const message = await response.json()
console.log(message.status, message.parts, message.price_eur)
// accepted 1 0.0298

Reading the response

The response is synchronous: by the time it arrives, the outcome is decided and the charge applied. The fields that matter: status ("accepted" = taken over for delivery), parts (the billed parts), price_eur (the total cost).

price_eur is a string with 4 decimals, not a number: it is money, and floats round. Compare it and store it as a string or a decimal type.

Errors come back as JSON with a stable code field to branch on: insufficient balance is INSUFFICIENT_BALANCE (402), a malformed body VALIDATION_FAILED (400), a wrong key INVALID_API_KEY (401).

Response

200 OK

{
  "id": "0198f3c1-6b2a-7c41-9f0e-2d4a8b5c1e73",
  "status": "accepted",
  "encoding": "gsm7",
  "parts": 1,
  "price_eur": "0.0298"
}

Where to find the message afterwards

Every send shows up in the dashboard message log: recipient, parts, price and status recorded at send time. The id in the response is the same one you see in the log.

To check status over the API, GET /api/v1/sms/:id returns the same object as the send response, with the status updated.

Live in two minutes

Ready to send your first SMS or WhatsApp message?

Sign up, confirm your email, top up by card and send your first message from the browser, no code needed.

SMS packages or a monthly plan by card, a credit line for volume senders — cancel any time.