Skip to content
Loyvo

API reference

SMS API

Send SMS and personalised campaigns to Sri Lankan numbers, check delivery and sender IDs.

Authenticate with a Loyvo API key with sms:send / sms:read (app.loyvo.lk → Settings → API keys):

Authorization: Bearer lvo_live_xxxxxxxxxxxxxxxxxxxxxxxx
  • Live keys (lvo_live_…) send real SMS.
  • Test keys (lvo_test_…) behave exactly the same (same validation, same responses) but messages are never sent to phones; they are marked delivered within seconds and carry "test": true.

Numbers: Sri Lankan mobiles in any common format (0771234567, +94 77 123 4567, 94771234567). They are returned normalized as 94771234567.

SMS parts: standard GSM rules. 160 characters per SMS (153 per part when longer); any Sinhala/Tamil/emoji character makes the whole message Unicode: 70 per SMS (67 per part). Maximum 6 parts.

Retries: send an Idempotency-Key header (any unique string up to 100 characters, e.g. a UUID or your order ID) on POST requests. Repeating a request with the same key and body within 24 hours returns the original response (header Idempotent-Replayed: true) and never sends twice.

Errors always look like:

{"error": {"code": "validation_failed", "message": "…", "field": "to", "request_id": "req_…"}}

Rate limits: per API key. On 429, wait for the Retry-After seconds.

Base URL
https://api.loyvo.lk
Authentication
Authorization: Bearer lvo_test_xxxxxxxxxxxxxxxxxxxxxxxx

Use a Loyvo API key with sms:send / sms:read (app.loyvo.lk → Settings → API keys), sent as a bearer token. Test keys (lvo_test_) never reach a phone. More about keys · Download OpenAPI

SMS

Send one message to up to 100 numbers

post/v1/sms/send

Requires the send permission. Duplicate numbers are sent once.

Headers

  • Idempotency-Keystring

    Makes retries safe. Same key + same body within 24h returns the original response.

Body parameters

  • sender_idstringRequired

    Approved sender ID: the mask (e.g. LOYVO) or its ID (sid_…). Free trial: until you have your own approved sender ID, use the trial sender ID listed by GET /v1/sender-ids (trial: true) or leave this empty. Trial SMS can only go to the mobile number verified in the portal and end with "Sent via Loyvo SMS (trial)", which counts toward the message length.

  • tostring or arrayRequired

    One number, a comma-separated string, or an array (max 100).

  • messagestringRequired

    Text, up to 6 SMS parts.

  • referencestring

    Your own ID

  • schedule_atstring (date-time)

    Send later (1 minute to 90 days ahead). Include an offset, e.g. +05:30.

Returns

  • 202Accepted and queued (or scheduled).
  • 400The request is malformed, or a business rule failed.
  • 401No key, or the key is invalid or revoked.
  • 403The key is valid but not allowed to do this.
  • 409Conflict: the action no longer applies, or the same Idempotency-Key is still being processed.
  • 422Validation failed: a field is missing or invalid.
  • 429Too many requests. Wait for the Retry-After seconds, then retry.

Errors use the standard format. See Errors.

POST /v1/sms/send
curl -X POST "https://api.loyvo.lk/v1/sms/send" \
  -H "Authorization: Bearer lvo_test_xxxxxxxxxxxxxxxxxxxxxxxx" \
  -H "Content-Type: application/json" \
  -d '{
  "sender_id": "LOYVO",
  "to": "0771234567",
  "message": "Your OTP is 482913",
  "reference": "otp-1055"
}'
Response 202
{
  "campaign_id": "cmp_df2jgawxjjy2bcoiwyvsentt",
  "sender_id": "LOYVO",
  "encoding": "GSM-7",
  "segments": 1,
  "total_segments": 1,
  "recipients": 1,
  "status": "queued",
  "schedule_at": null,
  "test": false,
  "messages": [
    {
      "id": "msg_5iu6f43yfldhvqilzajrh2qq",
      "to": "94771234567",
      "status": "queued"
    }
  ]
}

Send a campaign to up to 10,000 numbers, optionally personalised

post/v1/sms/bulk

Requires the send permission. Use {{variable}} placeholders in message and give each recipient its vars. Variable names are case-insensitive. Duplicate numbers are sent once; any invalid number rejects the whole request (the error lists the rows) so you always know exactly who receives the SMS.

Headers

  • Idempotency-Keystring

    Makes retries safe. Same key + same body within 24h returns the original response.

Body parameters

  • sender_idstringRequired
  • namestring

    Campaign name shown in the portal.

  • messagestringRequired

    Text or template with {{placeholders}}.

  • recipientsarray of objectsRequired
    Show child attributes
    • tostringRequired
    • varsobject

      Values for {{placeholders}} in the message.

  • referencestring
  • schedule_atstring (date-time)

Returns

  • 202Accepted and queued (or scheduled).
  • 400The request is malformed, or a business rule failed.
  • 401No key, or the key is invalid or revoked.
  • 403The key is valid but not allowed to do this.
  • 409Conflict: the action no longer applies, or the same Idempotency-Key is still being processed.
  • 413The request body is too large.
  • 422Validation failed: a field is missing or invalid.
  • 429Too many requests. Wait for the Retry-After seconds, then retry.

Errors use the standard format. See Errors.

POST /v1/sms/bulk
curl -X POST "https://api.loyvo.lk/v1/sms/bulk" \
  -H "Authorization: Bearer lvo_test_xxxxxxxxxxxxxxxxxxxxxxxx" \
  -H "Content-Type: application/json" \
  -d '{
  "sender_id": "LOYVO",
  "name": "Order ready",
  "message": "Hi {{name}}, order {{order}} is ready for pickup.",
  "recipients": [
    {
      "to": "0771234567",
      "vars": {
        "name": "Kamal",
        "order": "A-101"
      }
    },
    {
      "to": "0712345678",
      "vars": {
        "name": "Nimal",
        "order": "A-102"
      }
    }
  ]
}'
Response 202
{
  "campaign_id": "cmp_df2jgawxjjy2bcoiwyvsentt",
  "sender_id": "LOYVO",
  "encoding": "GSM-7",
  "segments": 1,
  "total_segments": 1,
  "recipients": 1,
  "status": "queued",
  "schedule_at": null,
  "test": false,
  "messages": [
    {
      "id": "msg_5iu6f43yfldhvqilzajrh2qq",
      "to": "94771234567",
      "status": "queued"
    }
  ]
}

Get one message and its delivery status

get/v1/sms/{id}

Requires the read permission.

Path parameters

  • idstringRequired

Returns

  • 200The message.
  • 401No key, or the key is invalid or revoked.
  • 404The endpoint or the object doesn't exist.

Errors use the standard format. See Errors.

GET /v1/sms/{id}
curl "https://api.loyvo.lk/v1/sms/abc123" \
  -H "Authorization: Bearer lvo_test_xxxxxxxxxxxxxxxxxxxxxxxx"
Response 200
{
  "id": "6c0f2b9e-1d2a-4c7e-9a51-0b7e4d2f3a10",
  "campaign_id": "6c0f2b9e-1d2a-4c7e-9a51-0b7e4d2f3a10",
  "to": "94771234567",
  "sender_id": "LOYVO",
  "message": "Hi Nimali, your order is ready to collect.",
  "encoding": "GSM-7",
  "segments": 1,
  "status": "scheduled",
  "failure_reason": null,
  "source": "portal",
  "test": false,
  "reference": "order-1042",
  "created_at": "2026-11-17T10:00:00+05:30",
  "schedule_at": null,
  "sent_at": null,
  "delivered_at": null,
  "failed_at": null
}

Campaigns

Get a campaign with its messages

get/v1/campaigns/{id}

Requires the read permission. Messages are paginated.

Path parameters

  • idstringRequired

Query parameters

  • pageinteger
  • page_sizeinteger

Returns

  • 200The campaign and a page of its messages.
  • 401No key, or the key is invalid or revoked.
  • 404The endpoint or the object doesn't exist.

Errors use the standard format. See Errors.

GET /v1/campaigns/{id}
curl "https://api.loyvo.lk/v1/campaigns/abc123" \
  -H "Authorization: Bearer lvo_test_xxxxxxxxxxxxxxxxxxxxxxxx"
Response 200
{
  "campaign": {
    "id": "6c0f2b9e-1d2a-4c7e-9a51-0b7e4d2f3a10",
    "name": "November offer",
    "type": "single",
    "source": "portal",
    "sender_id": "LOYVO",
    "message": "Hi Nimali, your order is ready to collect.",
    "personalized": false,
    "test": false,
    "recipients": 1,
    "segments": 1,
    "status": "scheduled",
    "reference": "order-1042",
    "schedule_at": null,
    "cancelled_at": null,
    "created_at": "2026-11-17T10:00:00+05:30",
    "counts": {
      "scheduled": 1,
      "queued": 1,
      "sent": 1,
      "delivered": 1,
      "failed": 1,
      "cancelled": 1
    }
  },
  "messages": [
    {
      "id": "6c0f2b9e-1d2a-4c7e-9a51-0b7e4d2f3a10",
      "campaign_id": "6c0f2b9e-1d2a-4c7e-9a51-0b7e4d2f3a10",
      "to": "94771234567",
      "sender_id": "LOYVO",
      "message": "Hi Nimali, your order is ready to collect.",
      "encoding": "GSM-7",
      "segments": 1,
      "status": "scheduled",
      "failure_reason": null,
      "source": "portal",
      "test": false,
      "reference": "order-1042",
      "created_at": "2026-11-17T10:00:00+05:30",
      "schedule_at": null,
      "sent_at": null,
      "delivered_at": null,
      "failed_at": null
    }
  ],
  "pagination": {
    "page": 1,
    "page_size": 50,
    "total": 1
  }
}

Cancel a scheduled campaign

post/v1/campaigns/{id}/cancel

Requires the send permission. Cancels every message that hasn't started sending yet.

Path parameters

  • idstringRequired

Returns

  • 200The updated campaign.
  • 401No key, or the key is invalid or revoked.
  • 404The endpoint or the object doesn't exist.
  • 409not_cancellable: the campaign already started sending.

Errors use the standard format. See Errors.

POST /v1/campaigns/{id}/cancel
curl -X POST "https://api.loyvo.lk/v1/campaigns/abc123/cancel" \
  -H "Authorization: Bearer lvo_test_xxxxxxxxxxxxxxxxxxxxxxxx"
Response 200
{
  "id": "6c0f2b9e-1d2a-4c7e-9a51-0b7e4d2f3a10",
  "name": "November offer",
  "type": "single",
  "source": "portal",
  "sender_id": "LOYVO",
  "message": "Hi Nimali, your order is ready to collect.",
  "personalized": false,
  "test": false,
  "recipients": 1,
  "segments": 1,
  "status": "scheduled",
  "reference": "order-1042",
  "schedule_at": null,
  "cancelled_at": null,
  "created_at": "2026-11-17T10:00:00+05:30",
  "counts": {
    "scheduled": 1,
    "queued": 1,
    "sent": 1,
    "delivered": 1,
    "failed": 1,
    "cancelled": 1
  }
}

Sender IDs

List your sender IDs

get/v1/sender-ids

Requires the read permission. Only approved sender IDs can send.

Returns

  • 200Your sender IDs.
  • 401No key, or the key is invalid or revoked.

Errors use the standard format. See Errors.

GET /v1/sender-ids
curl "https://api.loyvo.lk/v1/sender-ids" \
  -H "Authorization: Bearer lvo_test_xxxxxxxxxxxxxxxxxxxxxxxx"
Response 200
{
  "data": [
    {
      "id": "sid_2gf66bdlygu6zdjmdfztqovh",
      "mask": "LOYVO",
      "status": "pending",
      "created_at": "2026-11-17T10:00:00+05:30",
      "trial": false
    }
  ]
}

Balance

Your SMS credits

get/v1/balance

Requires the read permission. One credit sends one SMS part.

Returns

  • 200Your balance.
  • 401No key, or the key is invalid or revoked.

Errors use the standard format. See Errors.

GET /v1/balance
curl "https://api.loyvo.lk/v1/balance" \
  -H "Authorization: Bearer lvo_test_xxxxxxxxxxxxxxxxxxxxxxxx"
Response 200
{
  "credits": 4820,
  "buckets": [
    {}
  ],
  "wallet_cents": 0,
  "rate_per_part_cents": 75,
  "currency": "LKR",
  "plan": {}
}