Skip to content

Service Notifications API

The Service Notifications API lets your systems send a transactional message, such as an OTP, an order update or a payment confirmation, the moment the event happens. One endpoint handles Email, SMS, WhatsApp and RCS. FirstHive routes each message through the provider configured for that notification, fills in the template, shortens and tracks links, and logs every call.

This article is for developers. To set up the notification itself, see Service Notifications.

Before you start

  1. Get API credentials. Your FirstHive team issues an API key and a secret key for your account. They’re for server-to-server integrations only.
  2. Create the service notification in Communication > Service Notification: add the channel, choose the sender, and create the template with its placeholders.
  3. Activate it. Change its status from Draft to Active. Requests to a Draft notification are rejected.
  4. Get the endpoint and Service ID. On the notification’s ⋮ menu, choose View Endpoint. It shows the Endpoint URL, the Service ID and a link to the full API docs. Each notification has its own Service ID.

Authentication

Send both headers on every request:

X-FH-Key-ID: <your_api_key>
X-FH-Key-Secret: <your_secret_key>
Content-Type: application/json

Requests with missing or wrong credentials get 401 Unauthorized. Keep the secret key on your servers; never put it in a website, app or public code repository.

Send a notification

POST to the Endpoint URL shown in View Endpoint (path /api/v1/notify/send).

{
"serviceId": 1001,
"channelType": "WHATSAPP",
"recipient": "+919876543210",
"attributes": ["John", "5829"],
"buttonParams": ["https://example.com/verify?token=abc123"]
}
FieldTypeRequiredDescription
serviceIdnumberYesThe Service ID from View Endpoint.
channelTypestringYesEMAIL, SMS, WHATSAPP or RCS.
recipientstringYesAn email address for EMAIL; a phone number with country code, such as +919876543210, for the others.
attributeslist of stringsNoValues for the template’s placeholders {{1}}, {{2}} and so on, in order.
buttonParamslist of stringsNoFull URLs for the template’s dynamic URL buttons, in button order. WhatsApp and RCS only.

Success response

{
"success": true,
"data": {
"success": true,
"messageId": "msg_abc123def456",
"message": "Notification sent successfully"
},
"timestamp": 1711234567890
}

Error response

{
"success": false,
"data": {
"success": false,
"message": "Failed to send notification",
"errorCode": "CHANNEL_NOT_CONFIGURED"
},
"timestamp": 1711234567890
}

A 200 status means the request was processed. Always check the success field in the body.

Placeholders

Values in attributes replace the template’s numbered placeholders by position: the first value fills {{1}}, the second fills {{2}}, and so on.

TemplateattributesMessage sent
Dear {{1}}, your OTP is {{2}}. Valid for {{3}} min.["John", "5829", "5"]Dear John, your OTP is 5829. Valid for 5 min.
Hi {{1}}, your order {{2}} has been shipped.["John", "ORD-001"]Hi John, your order ORD-001 has been shipped.

There’s no endpoint to look up a template’s placeholders, so record the order and meaning of each placeholder when you create the template, and share it with your developers. For WhatsApp, the number and order of values must match the approved template exactly.

Examples by channel

SMS

{ "serviceId": 1001, "channelType": "SMS", "recipient": "+919876543210", "attributes": ["John", "5829"] }

Email

{ "serviceId": 1002, "channelType": "EMAIL", "recipient": "user@example.com", "attributes": ["John Doe", "ORD-2026-001"] }

WhatsApp with a dynamic URL button

{ "serviceId": 1003, "channelType": "WHATSAPP", "recipient": "+919876543210", "attributes": ["John", "482910"], "buttonParams": ["https://example.com/verify?token=abc123"] }

RCS with a dynamic URL button

{ "serviceId": 1004, "channelType": "RCS", "recipient": "+919876543210", "attributes": ["John", "ORD-2026-001"], "buttonParams": ["https://example.com/track?id=ORD-2026-001"] }

For WhatsApp and RCS, FirstHive shortens links automatically and tracks clicks. Always send the original, full URL.

  • A URL in attributes (any value starting with http:// or https://) is replaced in the message with a tracked short link.
  • A URL in buttonParams is shortened, and the button receives the short code.
  • When the customer clicks, the click is recorded and they’re redirected to the original URL.
  • Values that aren’t URLs, such as names or OTPs, are sent unchanged.

Links in SMS and Email service notifications are sent as you pass them, without shortening. See Short URLs and Vanity URLs.

Errors

StatusMeaning
200Request processed; check success in the body.
400Bad request: a required field is missing, or the input failed validation.
401Missing or invalid API key or secret.
404The Service ID doesn’t exist.
409Conflict: duplicate resource.
500Server error.
ProblemLikely causeWhat to do
Authentication requiredKey or secret missing or wrong.Send both headers on every request, with the values issued to you.
Service not foundWrong serviceId.Copy the Service ID from View Endpoint.
Channel not configuredThe channel isn’t set up for this notification.Add and configure the channel in the notification.
Template not foundNo template for the channel.Create the template in the notification.
Validation errorA required field is missing, or the input contains script or query code.Check and correct the request.
Service temporarily unavailableThe messaging provider is failing and FirstHive has paused sending to protect it.Retry after 30 seconds, with exponential backoff.

Temporary pauses

If the messaging provider starts failing (half of the last 10 calls), FirstHive pauses sending through it for 30 seconds and returns an error, then tries a few test calls before resuming. Build retries into your integration: wait 30 seconds, then increase the delay on each retry.

Security and logging

  • All input is checked, and requests containing scripts or database query operators are rejected.
  • Recipients are masked in logs, for example +91****3210 and j***@example.com.
  • Every call is logged with the caller, request, response status, client IP and duration.

Checklist

  1. Get your API key and secret key from your FirstHive team.
  2. Create the service notification, add the channel and sender, and create the template with its placeholders.
  3. Change the status from Draft to Active.
  4. Copy the Endpoint URL and Service ID from View Endpoint.
  5. Send a test request to your own phone or email, then go live.