Giftrocket for SureCart Documentation

⌘K
  1. Home
  2. Docs
  3. Giftrocket for SureCart D...
  4. 15. Pro – Reports & Integ...
  5. 15.4 REST API

15.4 REST API

The REST API lets other systems, such as a till, an app or an automation tool, check, use and issue gift cards.

Turn On the API

  1. Go to GiftRocket → Settings → API & Webhooks.
  2. Switch on REST API Status.
  3. Copy the API Base URL and the GiftRocket API Key (click Show).
  4. Click Save API & Webhook Settings. The key only works after you save.
API & Webhooks settings with the REST API Status switch, API Base URL, API key and the Available Endpoints table

Note: Keep the key secret. Regenerate creates a new key and the old one stops working once you save.

Authentication

Send the key in a header with every request:

X-GiftRocketSure-Key: your_api_key
# or
Authorization: Bearer your_api_key

Endpoints

All paths start with https://yoursite.com/wp-json/giftrocket-sure/v1.

MethodPathDoesBody
GET/cards/{code}Get a card’s balance, status, currency, recipient and expiryNone
POST/cards/validateCheck whether a card can be used and how much appliescode, subtotal
POST/cards/deductTake an amount from a cardcode, amount, order_id, note
POST/cards/topupAdd an amount to a cardcode, amount, order_id, note
POST/cards/createIssue a new card (no email is sent)amount, recipient_name, recipient_email, custom_code, expire_date, message
POST/cards/voidDisable a cardcode, reason
GET/system/pingCheck the connection and your keyNone

Example

curl -X POST https://yoursite.com/wp-json/giftrocket-sure/v1/cards/deduct \
  -H "X-GiftRocketSure-Key: your_api_key" \
  -H "Content-Type: application/json" \
  -d '{"code":"A4PS-UL3E-7MXH-LJ4P","amount":20,"order_id":"TILL-1042"}'

A successful deduction returns balance_before, balance_after and the card’s new status.

Errors

StatusCodeMeaning
401giftrocketsure_invalid_api_keyThe key is missing or wrong.
403giftrocketsure_api_disabledREST API Status is switched off.
404card_not_foundNo card has this code.
400insufficient_balanceThe card has less than the amount requested.
400card_not_activeThe card is used up, expired or disabled.

How can we help?