API reference

The basics

Endpoints

GET /api/v1/campaigns

List the business's campaigns. The campaigns of the key's business that are live and can take a session: running, not archived, not waiting to start, and not a page that takes no customers. Use it to fill a campaign picker on your side. Being listed does not guarantee a visit will be accepted: a visit to a campaign set up in a way that cannot take a reported visit is still refused with wrong_flow. The list says nothing about customers, rewards or figures.

Purpose needed: Creates links or Records visits (either). Limit: 60 calls a minute for each connection.

No request body.

Answer (200)

FieldTypeAlways thereMeaning
campaignslist of objectyesThe business's campaigns that are live and can take a session.
campaigns[].campaign_idstringyesThe id to send as campaign_id.
campaigns[].namestringyesThe name shown for this campaign: the label customers see on its card.
campaigns[].identifierslist of string: phone, emailyesWhat identifies a customer on this campaign. One entry: a visit must carry that one. Two entries: either is enough.

Refusals

StatusCodeWhen
401key_missingNo Authorization header was sent, or it is not in the form Bearer <key>: the word Bearer (its letter case does not matter), then one space, then the key.
401key_invalidThe key is not one we know: mistyped, cut short, in the wrong form, or a key from another deployment.
401key_revokedThe key was switched off, or its connection was switched off.
401key_expiredThe key was replaced and its 7 days have passed.
401business_offThe business has been switched off on the platform, so none of its connections work for now. The key itself is not at fault.
429rate_limitedToo many calls in the last minute.
500errorSomething failed on our side.
503busyThe service is busy for a moment.

POST /api/v1/visits

Record a visit. Records a visit for a customer you identify by phone number or email address, as if staff had logged it on the business's dashboard: the same rewards and the same limits. The answer only says that the call was accepted, with a receipt id; it never says what the customer earned. The visit is timed when we receive it - a time you send is not read. Within 90 days, sending the same request_id again on the same connection returns the first call's receipt and records nothing. The order is: the key is accepted; the connection has the "Records visits" purpose and is within its limit (otherwise scope_denied or rate_limited); campaign_id and request_id are present and well formed; then a repeat gets the first call's receipt, before the campaign, the customer's details, the bill amount or the branch are looked at, so it holds whatever the rest of the repeat's body says and even if the campaign has since been archived. After 90 days the id is forgotten: the request is checked like a new one and gets a new receipt id. If the earlier request recorded a visit, no second visit or reward is recorded. If the earlier request only joined a visit already in progress, the repeat (once that visit's window has closed) is recorded as a new visit and can give a reward. On a "play first, then identify" campaign the wait between visits is kept per customer for a reported visit (a customer's own scan is still checked on that customer's device): a second report for the same customer inside the wait (after the visit window has closed) is accepted and gets its receipt id, but it is not recorded as a visit and it gives no reward.

Purpose needed: Records visits. Limit: 120 calls a minute for each connection.

Request fields

FieldTypeRequiredMeaning
campaign_idstringyesA campaign of the key's business, from the campaign list.
request_idstringyesYour own id for this visit - the bill or order number. 1 to 64 visible ASCII characters, no spaces. Never a phone number or an email address. Remembered for 90 days per connection.
phonestringnoThe customer's phone number, in the format of the business's country: a Nepal business takes 10 digits, optionally preceded by +977 or 977. A full international number (+ and the calling code) is also accepted. Spaces and dashes are ignored. It is stored with its calling code.
emailstringnoThe customer's email address. If you send both a phone number and an email address and they belong to two different customers, the phone number decides.
namestringnoThe customer's name. Optional. Stored only when the campaign's form collects a name; otherwise it is accepted and left out.
txn_valuenumber or stringnoThe bill amount, in the business's currency. Optional. Send a number of zero or more; plain text that is such a number, like "12.5", is read too. Anything else (for example "1,200.00", a negative number, or a number too large to be exact, above 9007199254740991) is ignored: the call goes ahead as if no amount was sent.
branchstringnoYour own code for the branch. Optional. A code we do not recognise is ignored.

Answer (200)

FieldTypeAlways thereMeaning
acceptedbooleanyesAlways true: the visit was received.
event_idstringyesA receipt id for this call. Keep it for support questions. It is NOT the event_id of the visit.recorded webhook.

Refusals

StatusCodeWhen
400invalid_jsonThe request body is not valid JSON.
400body_not_objectThe request body is valid JSON but is not an object: for example a bare number, null or a list.
400unsupported_charsetThe request body is not in UTF-8.
400unsupported_encodingThe request body is compressed in a way we do not read (Content-Encoding).
400campaign_requiredcampaign_id is missing.
400request_id_requiredrequest_id is missing.
400request_id_invalidrequest_id must be 1 to 64 visible ASCII characters with no spaces.
400no_sessionsThis campaign is a kind of page that takes no session links and no visits.
400wrong_flowThis campaign is set up in a way that cannot take a visit recorded for it.
400identifier_requiredThe campaign needs a phone number or an email address and the call carried none it can use. field names what to send.
400invalid_phoneThe phone number is not valid in the format of the business's country: the national number, with or without the calling code (a Nepal business: 10 digits, with or without +977).
400invalid_emailThe email address is not valid.
401key_missingNo Authorization header was sent, or it is not in the form Bearer <key>: the word Bearer (its letter case does not matter), then one space, then the key.
401key_invalidThe key is not one we know: mistyped, cut short, in the wrong form, or a key from another deployment.
401key_revokedThe key was switched off, or its connection was switched off.
401key_expiredThe key was replaced and its 7 days have passed.
401business_offThe business has been switched off on the platform, so none of its connections work for now. The key itself is not at fault.
403scope_deniedThe connection's purpose does not cover this endpoint (for example a connection that only creates links tried to record a visit).
404campaign_not_foundThe business has no campaign with this id. Another business's campaign answers the same way, on purpose.
409campaign_archivedThe business has archived this campaign.
409campaign_not_availableThe campaign exists but is not taking customers at the moment.
413payload_too_largeThe request body is far larger than any request here needs to be.
429rate_limitedToo many calls in the last minute.
500errorSomething failed on our side.
503busyThe service is busy for a moment.

Examples

Each example below is run against the platform by our own tests every time the platform changes, so it cannot go out of date. Values that differ on every call (the link, the times, the receipt ids) are samples.

Example: List the business's campaigns

Request

GET /api/v1/campaigns
Authorization: Bearer cpk_3f9a1c2b4d5e_<secret>

Answer

HTTP 200

{
  "campaigns": [
    {
      "campaign_id": "cmp_example",
      "name": "Acme Cafe",
      "identifiers": [
        "phone"
      ]
    }
  ]
}

Example: A session link, with the bill amount and a branch code

Request

POST /api/v1/links
Authorization: Bearer cpk_3f9a1c2b4d5e_<secret>
Content-Type: application/json

{
  "campaign_id": "cmp_example",
  "txn_value": 1250,
  "branch": "KTM-07"
}

Answer

HTTP 200

{
  "url": "https://app.rewardsnp.com/c/cli_example/cmp_example.html?sid=eyJjIjoiY21wX2V4YW1wbGUifQ.c2FtcGxl",
  "expires_at": "2026-10-03T12:49:56.000Z"
}

The values of url and expires_at here are samples: they are different on every call.

Example: A bill amount we cannot use still gets a link

The amount is text with a comma, not a number. The link is created without an amount, and the business's Connections card shows the value under "what we ignored".

Request

POST /api/v1/links
Authorization: Bearer cpk_3f9a1c2b4d5e_<secret>
Content-Type: application/json

{
  "campaign_id": "cmp_example",
  "txn_value": "1,250.00"
}

Answer

HTTP 200

{
  "url": "https://app.rewardsnp.com/c/cli_example/cmp_example.html?sid=eyJjIjoiY21wX2V4YW1wbGUifQ.c2FtcGxl",
  "expires_at": "2026-10-03T12:49:56.000Z"
}

The values of url and expires_at here are samples: they are different on every call.

Example: Record a visit

Request

POST /api/v1/visits
Authorization: Bearer cpk_3f9a1c2b4d5e_<secret>
Content-Type: application/json

{
  "campaign_id": "cmp_example",
  "request_id": "BILL-10482",
  "phone": "9801234567",
  "txn_value": 1250
}

Answer

HTTP 200

{
  "accepted": true,
  "event_id": "rcp_8c1f0a2b3d4e5f60"
}

The value of event_id here is a sample: it is different on every call.

Example: The same visit sent again returns the same receipt

Same request_id, same connection, within 90 days: once the key, the purpose, the limit and the shape of campaign_id and request_id have passed, the first call's receipt comes back and nothing new is recorded, whatever the rest of the repeat's body says.

Request

POST /api/v1/visits
Authorization: Bearer cpk_3f9a1c2b4d5e_<secret>
Content-Type: application/json

{
  "campaign_id": "cmp_example",
  "request_id": "BILL-10482",
  "phone": "9801234567",
  "txn_value": 1250
}

Answer

HTTP 200

{
  "accepted": true,
  "event_id": "rcp_8c1f0a2b3d4e5f60"
}

The value of event_id is the one the example “Record a visit” returned.

Example: A bill with no customer details

The campaign identifies customers by phone number and the call carried none. Nothing is recorded. For a till that reports every bill, this is the normal answer for a bill with no customer.

Request

POST /api/v1/visits
Authorization: Bearer cpk_3f9a1c2b4d5e_<secret>
Content-Type: application/json

{
  "campaign_id": "cmp_example",
  "request_id": "BILL-10483",
  "txn_value": 480
}

Answer

HTTP 400

{
  "error": {
    "code": "identifier_required",
    "message": "This campaign needs the customer's phone number or email address.",
    "field": "phone"
  }
}

Example: A connection that only creates links tries to record a visit

Request

POST /api/v1/visits
Authorization: Bearer cpk_7a0b9c8d1e2f_<secret>
Content-Type: application/json

{
  "campaign_id": "cmp_example",
  "request_id": "BILL-10484",
  "phone": "9801234567"
}

Answer

HTTP 403

{
  "error": {
    "code": "scope_denied",
    "message": "This connection is not set up for this kind of request."
  }
}

Example: A key we do not know

Request

GET /api/v1/campaigns
Authorization: Bearer cpk_000000000000_0000000000000000000000000000000000000000000000000000000000000000

Answer

HTTP 401

{
  "error": {
    "code": "key_invalid",
    "message": "This key is not recognised."
  }
}

Sending a visit twice

request_id makes a visit safe to send again. The first call with a given request_id on a connection decides the outcome; for 90 days, every later call with the same request_id that passes the first checks listed below returns the same receipt and records nothing, even if the rest of the request is different.

Errors

Every answer that is not a success is { "error": { "code", "message", "field" } }. field is present only when the refusal is about one field. Decide from code.

CodeStatusWhat it meansWhat to do
key_missing401No Authorization header was sent, or it is not in the form Bearer <key>: the word Bearer (its letter case does not matter), then one space, then the key.Send the header on every call, exactly in that form.
key_invalid401The key is not one we know: mistyped, cut short, in the wrong form, or a key from another deployment.Check the key you stored. Do not retry with the same key.
key_revoked401The key was switched off, or its connection was switched off.Tell the business. It creates a new connection or key in its dashboard. Do not retry.
key_expired401The key was replaced and its 7 days have passed.Use the key that replaced it.
business_off401The business has been switched off on the platform, so none of its connections work for now. The key itself is not at fault.Tell the business. Do not retry until it is switched back on; nothing was recorded.
scope_denied403The connection's purpose does not cover this endpoint (for example a connection that only creates links tried to record a visit).The business creates a connection with the right purpose. Do not retry.
campaign_not_found404The business has no campaign with this id. Another business's campaign answers the same way, on purpose.Fetch the campaign list and use an id from it.
campaign_archived409The business has archived this campaign.Stop sending for this campaign. Show something else.
campaign_not_available409The campaign exists but is not taking customers at the moment.Show something else now; the same call may succeed later.
invalid_json400The request body is not valid JSON.Fix the request. Do not retry unchanged.
body_not_object400The request body is valid JSON but is not an object: for example a bare number, null or a list.Send a JSON object, in { }. Do not retry unchanged.
unsupported_charset400The request body is not in UTF-8.Send the body as UTF-8 text (Content-Type: application/json; charset=utf-8). Do not retry unchanged.
unsupported_encoding400The request body is compressed in a way we do not read (Content-Encoding).Send the body uncompressed. Do not retry unchanged.
campaign_required400campaign_id is missing.Send it.
no_sessions400This campaign is a kind of page that takes no session links and no visits.Use a campaign from the campaign list - it only lists campaigns that can be used here.
wrong_flow400This campaign is set up in a way that cannot take a visit recorded for it.Use a session link for this campaign instead.
request_id_required400request_id is missing.Send your bill or order number.
request_id_invalid400request_id must be 1 to 64 visible ASCII characters with no spaces.Send a shorter or plainer value.
identifier_required400The campaign needs a phone number or an email address and the call carried none it can use. field names what to send.Normal for a bill with no customer details: nothing was recorded. Do not retry.
invalid_phone400The phone number is not valid in the format of the business's country: the national number, with or without the calling code (a Nepal business: 10 digits, with or without +977).Nothing was recorded. Correct the number or drop the visit.
invalid_email400The email address is not valid.Nothing was recorded. Correct the address or drop the visit.
payload_too_large413The request body is far larger than any request here needs to be.Send only the fields the endpoint describes.
not_found404The address or the method is not one of the endpoints of this API.Check the address and the method against this reference.
rate_limited429Too many calls in the last minute.Wait the number of seconds in the Retry-After header, then try again.
error500Something failed on our side.Try again after a short wait. For a visit, send the same request_id so it cannot be counted twice.
busy503The service is busy for a moment.Wait the number of seconds in the Retry-After header, then try again. For a visit, send the same request_id: the retry cannot be counted twice.

Rate limits

Counted per connection, per minute. Over the limit: 429, code rate_limited, and a Retry-After header with the seconds to wait.

EndpointCalls a minute, for each connection
GET /api/v1/campaigns60
POST /api/v1/links600
POST /api/v1/visits120