Gift Card Issuance

Read the gift catalog, issue a gift card to an employee or to someone outside the company, and follow delivery

Overview

This guide covers what a tenant administrator can do over the Master Data API: list gift brands the company may issue, read the amounts a brand accepts, issue one gift card per recipient, follow its status, and work with the delivery email.

Platform setup stays with Custodia support: connecting the GiftCrowd provider, API credentials, which brands a tenant may issue, and the gift activity with its annual budget. Issuance fails on the first call until that setup is in place.

European card programs use a different order-card payload. See Card issuance for date of birth, citizenship, phone, and address. Gift orders use the instruction fields on this page.

Disclaimer: The examples below are illustrative only. Replace every placeholder with your own sandbox or production values. All identifiers, tokens, and names in this page are fictitious.

The flow

  1. Read the catalog — GET /md/api/CardProducts returns the brands this tenant can issue.
  2. Read brand terms — GET /md/api/CardProducts/{id}/giftDetails returns amounts, currency, and fees.
  3. Issue the gift — POST /md/api/User/{id}/order-card creates one card per call.
  4. Follow the status — GET /md/api/Cards moves from UNACTIVATED to ACTIVE (or an error state). POST /md/api/Cards/{cardId}/refreshGiftStatus re-reads a pending order.
  5. Delivery — the platform emails the recipient when the card becomes ACTIVE. POST /md/api/Cards/{cardId}/resendGiftEmail sends that email again.

A gift is one card per recipient per call. There is no bulk endpoint. A bulk send is a loop over the issue step.

Before you start

What Why it matters
Role Gift cards are an administrator tool. The caller must hold admin or hr-admin. Employees cannot order a gift card for themselves. The platform rejects the attempt with Gift cards can only be issued by an administrator.
Token Every call is a normal authenticated Master Data request: Authorization: Bearer and x-appid. See Authentication and scopes.
Tenant setup The company must have the GiftCrowd provider connected with valid credentials, at least one gift brand enabled, and a gift activity template mapped to an active annual budget. Ask support to complete Gifts Hub setup.
Funds Each gift is drawn against the tenant's float with the issuer and booked to the gift budget. An order that exceeds what is available is rejected by the issuer.

Authentication and OAuth Scopes

Obtain an access token using the same client-credentials flow as in the Authentication guide. For order-card, the token request must ask for both of the following scopes in the scope array (order does not matter):

  • DEFAULT for standard application access.
  • f:Card/OrderCards so the issued token is allowed to order cards.

Authenticate (scope fragment)

{
  "client_id": "your-client-id",
  "client_secret": "your-client-secret",
  "scope": ["DEFAULT", "f:Card/OrderCards"],
  "grant_type": "client_credentials"
}

The token must also belong to a user with admin or hr-admin. A token that has f:Card/OrderCards and lacks that role is rejected with Gift cards can only be issued by an administrator.

Header Required Description
Authorization Yes Bearer access token from your application authentication flow (for example Bearer YOUR_ACCESS_TOKEN).
x-appid Yes Your application client id (same value you use for other MD API calls).
Content-Type Yes application/json on POST requests.

List Gift Brands

GET /md/api/CardProducts

Gift brands are card products owned by your company with a giftcrowd vendor. Only active ones can be issued. General card product fields are described in Card products.

Query Parameters

Use the filter query parameter. The filter is a JSON object passed as a URL-encoded string.

Parameter Type Description
filter object (JSON) Filter to this company's active GiftCrowd products. See the example below.

The where clause that returns issuable brands:

Filter

{
  "where": {
    "and": [
      {"companyId": "your-company-id"},
      {"vendor": {"like": "giftcrowd%"}},
      {"status": "active"}
    ]
  },
  "limit": 500
}

Example Request

Using cURL:

curl -G "https://sandbox.custodia-tech.com/md/api/CardProducts" \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
  -H "x-appid: YOUR_CLIENT_ID" \
  --data-urlencode 'filter={"where":{"and":[{"companyId":"your-company-id"},{"vendor":{"like":"giftcrowd%"}},{"status":"active"}]},"limit":500}'

Using JavaScript (fetch):

const filter = {
  where: {
    and: [
      { companyId: 'your-company-id' },
      { vendor: { like: 'giftcrowd%' } },
      { status: 'active' }
    ]
  },
  limit: 500
};

const filterParam = encodeURIComponent(JSON.stringify(filter));
const response = await fetch(`https://sandbox.custodia-tech.com/md/api/CardProducts?filter=${filterParam}`, {
  method: 'GET',
  headers: {
    'Authorization': `Bearer ${accessToken}`,
    'x-appid': clientId
  }
});

const brands = await response.json();

Response

Each row is a brand. Pass id when issuing. vendorRecordId is the issuer's brand id, useful if you keep your own mapping. A brand missing from this list is not enabled for the tenant. Support enables it; you cannot add one from the API.

200 OK (illustrative)

{
  "id": "11111111-2222-3333-4444-555555555555",
  "companyId": "your-company-id",
  "name": "Amazon",
  "productType": "giftcard/amazon",
  "vendor": "giftcrowd",
  "vendorRecordId": "AMZN-US",
  "status": "active"
}
Field Description
id Card product id. This is cardProductId on the issue call.
name Brand name shown to the recipient.
productType Product type, for example giftcard/amazon.
vendor giftcrowd for gift brands.
vendorRecordId Issuer brand id, for example AMZN-US.
status Only active brands can be issued.

Brand Terms

GET /md/api/CardProducts/{cardProductId}/giftDetails

Amounts and currency are per brand. The platform validates the issue amount against these terms, so read them before offering a choice. Replace {cardProductId} with the brand id from the catalog.

Example Request

Using cURL:

curl -X GET https://sandbox.custodia-tech.com/md/api/CardProducts/11111111-2222-3333-4444-555555555555/giftDetails \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
  -H "x-appid: YOUR_CLIENT_ID"

Using JavaScript (fetch):

const cardProductId = '11111111-2222-3333-4444-555555555555';

const response = await fetch(`https://sandbox.custodia-tech.com/md/api/CardProducts/${cardProductId}/giftDetails`, {
  method: 'GET',
  headers: {
    'Authorization': `Bearer ${accessToken}`,
    'x-appid': clientId
  }
});

const terms = await response.json();

Response

200 OK (illustrative)

{
  "name": "Amazon",
  "brandId": "AMZN-US",
  "description": "Amazon",
  "denominationType": "variable",
  "fixed": null,
  "variable": { "min": 20, "max": 200 },
  "activationFee": 0,
  "currency": "USD",
  "terms": "...",
  "redemptionInfo": "...",
  "imageUrl": "https://example.invalid/brand.png"
}
denominationType Allowed amount
fixed Exactly one of the values in fixed, for example [25, 50, 100].
variable Any amount from variable.min to variable.max inclusive.

Any other amount is rejected at issue time with a message naming the allowed values. A brand with neither fixed nor variable is misconfigured. Report it to support rather than retrying.

Issue a Gift Card

POST /md/api/User/{id}/order-card

Issues one gift card. Replace {id} using the recipient rules below. The broader order-card contract for other card products is in Users and Card issuance.

Which user id goes in the path

Recipient id in the path instructions
An employee of your company That employee's user id amount, recipientEmail, idempotencyKey. Leave sendToClient out.
Someone outside the company (a client, a partner, a candidate) Your own user id Add sendToClient: true plus firstname (and lastname), and optionally personalMessage.

For an external gift the platform creates or reuses an external user record for that email address and makes them the card owner. You stay recorded as the issuer. That is why the path carries your id, and the recipient is described in instructions.

Instruction fields

Field Required Description
cardProductId Yes Brand id from the catalog.
instructions.amount Yes Must satisfy the brand's denomination rule.
instructions.recipientEmail Yes Where the gift is delivered. For an employee gift it defaults to their account email if omitted.
instructions.idempotencyKey Strongly recommended A UUID you generate per recipient. Retrying with the same key returns the card already created. Without it, a retry after a timeout can double-issue.
instructions.sendToClient External only true marks the gift as going outside the company.
instructions.firstname / lastname External only At least a first name is required. It addresses the email.
instructions.personalMessage No Included in the delivery email for an external gift. Honoured on the first send only. It is not stored, so a later resend goes out without it.
One key per recipient: Generate the idempotencyKey before the first attempt and reuse it for every retry of that same gift. This is the protection against double-issuing.

Example: gift to an employee

Using cURL:

curl -X POST https://sandbox.custodia-tech.com/md/api/User/aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee/order-card \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
  -H "x-appid: YOUR_CLIENT_ID" \
  -H "Content-Type: application/json" \
  -d '{
  "cardProductId": "11111111-2222-3333-4444-555555555555",
  "instructions": {
    "amount": 50,
    "recipientEmail": "alex@example.com",
    "idempotencyKey": "7b1c6f2e-4a90-4c1d-9e2b-1234567890ab"
  }
}'

Using JavaScript (fetch):

const employeeId = 'aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee';

const response = await fetch(`https://sandbox.custodia-tech.com/md/api/User/${employeeId}/order-card`, {
  method: 'POST',
  headers: {
    'Authorization': `Bearer ${accessToken}`,
    'x-appid': clientId,
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    cardProductId: '11111111-2222-3333-4444-555555555555',
    instructions: {
      amount: 50,
      recipientEmail: 'alex@example.com',
      idempotencyKey: '7b1c6f2e-4a90-4c1d-9e2b-1234567890ab'
    }
  })
});

const card = await response.json();

Example: gift to someone outside the company

The path id is the administrator's own user id.

Using cURL:

curl -X POST https://sandbox.custodia-tech.com/md/api/User/dddddddd-eeee-ffff-0000-111111111111/order-card \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
  -H "x-appid: YOUR_CLIENT_ID" \
  -H "Content-Type: application/json" \
  -d '{
  "cardProductId": "11111111-2222-3333-4444-555555555555",
  "instructions": {
    "amount": 50,
    "recipientEmail": "alex@example.com",
    "idempotencyKey": "7b1c6f2e-4a90-4c1d-9e2b-1234567890ab",
    "sendToClient": true,
    "firstname": "Alex",
    "lastname": "Brown",
    "personalMessage": "Thank you for a great year"
  }
}'

Using JavaScript (fetch):

const adminUserId = 'dddddddd-eeee-ffff-0000-111111111111';

const response = await fetch(`https://sandbox.custodia-tech.com/md/api/User/${adminUserId}/order-card`, {
  method: 'POST',
  headers: {
    'Authorization': `Bearer ${accessToken}`,
    'x-appid': clientId,
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    cardProductId: '11111111-2222-3333-4444-555555555555',
    instructions: {
      amount: 50,
      recipientEmail: 'alex@example.com',
      idempotencyKey: '7b1c6f2e-4a90-4c1d-9e2b-1234567890ab',
      sendToClient: true,
      firstname: 'Alex',
      lastname: 'Brown',
      personalMessage: 'Thank you for a great year'
    }
  })
});

const card = await response.json();

Response

state is ACTIVE when the issuer fulfilled the order immediately, and UNACTIVATED when it is still working. Keep id. Every later call is keyed on it.

200 OK (illustrative)

{
  "id": "bbbbbbbb-cccc-dddd-eeee-ffffffffffff",
  "companyId": "your-company-id",
  "cardProductId": "11111111-2222-3333-4444-555555555555",
  "ownerId": "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee",
  "vendor": "giftcrowd",
  "state": "ACTIVE",
  "giftAmount": 50,
  "giftCurrency": "USD",
  "giftRecipientType": "client"
}
Budget: A failed order does not consume budget. The activity allocation is rolled back before the error is returned. Every successful gift books against the tenant's annual gift budget.

Follow the Status

GET /md/api/Cards

Gift cards live in the normal card list, filtered to the gift vendor. Treat UNACTIVATED as pending. Confirm with this call, or a single refresh, before telling anyone the gift is on its way.

Filter

{
  "where": {
    "and": [
      {"companyId": "your-company-id"},
      {"vendor": {"like": "giftcrowd%"}}
    ]
  },
  "limit": 100
}

Add {"id":"bbbbbbbb-cccc-dddd-eeee-ffffffffffff"} to the and for a single card, or {"state":"UNACTIVATED"} to list the ones still in flight.

Example Request

Using JavaScript (fetch):

const filter = {
  where: {
    and: [
      { companyId: 'your-company-id' },
      { vendor: { like: 'giftcrowd%' } },
      { id: 'bbbbbbbb-cccc-dddd-eeee-ffffffffffff' }
    ]
  },
  limit: 1
};

const filterParam = encodeURIComponent(JSON.stringify(filter));
const response = await fetch(`https://sandbox.custodia-tech.com/md/api/Cards?filter=${filterParam}`, {
  method: 'GET',
  headers: {
    'Authorization': `Bearer ${accessToken}`,
    'x-appid': clientId
  }
});

const cards = await response.json();

States

state Meaning
UNACTIVATED Ordered. The issuer has not confirmed yet. Normal for a few seconds to a few minutes.
ACTIVE Fulfilled. The delivery email has gone out, or is about to.
TERMINATED or any other value The order failed or was torn down. Treat as not delivered. The budget allocation is released.

Gift fields

As an admin or hr-admin you also get, per card:

Field Meaning
giftAmount, giftCurrency Face value.
giftRecipientType employee or client.
giftRecipientName, giftRecipientEmail Who it went to. Visible to admin, hr-admin, and support. Other roles get null.
giftSenderUserId Which admin issued it.
giftNotifiedAt When the delivery email was sent. null means the recipient has not been emailed yet.
Recipient data: The platform returns the gift fields listed above. Do not rely on reading the personal message back. It is included on the first email and is not stored on the card.

Refresh a pending card

POST /md/api/Cards/{cardId}/refreshGiftStatus

If a card sits in UNACTIVATED, ask the platform to re-read the order from the issuer. It returns the updated card. The call is valid while the card is UNACTIVATED. On an already-active card it errors. Poll sparingly. Every call reaches the issuer. Allowed for admin, hr-admin, or the card owner.

Using cURL:

curl -X POST https://sandbox.custodia-tech.com/md/api/Cards/bbbbbbbb-cccc-dddd-eeee-ffffffffffff/refreshGiftStatus \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
  -H "x-appid: YOUR_CLIENT_ID"

Using JavaScript (fetch):

const cardId = 'bbbbbbbb-cccc-dddd-eeee-ffffffffffff';

const response = await fetch(`https://sandbox.custodia-tech.com/md/api/Cards/${cardId}/refreshGiftStatus`, {
  method: 'POST',
  headers: {
    'Authorization': `Bearer ${accessToken}`,
    'x-appid': clientId
  }
});

const card = await response.json();

Delivery Email

The platform sends the email itself. When a gift becomes ACTIVE, Custodia mails the recipient once, from your company's branding, with the amount, the brand, your personal message if you supplied one, and the button that opens the gift. giftNotifiedAt on the card records that it happened.

Template code Used for
gift-card-ready Gifts to an employee (the card owner)
gift-card-for-recipient Gifts to an external recipient (sendToClient: true)

Render the message

POST /md/api/Templates/format

To show or archive what the recipient receives, render the template. The response is the rendered HTML. Use "category": "email-title" with the same code and parameters for the subject line, and add "asText": true when you want plain text.

If your tenant has saved its own version of a template, this returns your version. The platform default is used only when you have not overridden it.

Using cURL:

curl -X POST https://sandbox.custodia-tech.com/md/api/Templates/format \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
  -H "x-appid: YOUR_CLIENT_ID" \
  -H "Content-Type: application/json" \
  -d '{
  "props": {
    "category": "email",
    "code": "gift-card-for-recipient",
    "locale": "en-US",
    "parameters": {
      "brandName": "Amazon",
      "amount": 50,
      "currency": "USD",
      "recipientName": "Alex",
      "senderName": "Jordan",
      "companyName": "Acme Co",
      "personalMessage": "Thank you for a great year"
    }
  }
}'

Using JavaScript (fetch):

const response = await fetch('https://sandbox.custodia-tech.com/md/api/Templates/format', {
  method: 'POST',
  headers: {
    'Authorization': `Bearer ${accessToken}`,
    'x-appid': clientId,
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    props: {
      category: 'email',
      code: 'gift-card-for-recipient',
      locale: 'en-US',
      parameters: {
        brandName: 'Amazon',
        amount: 50,
        currency: 'USD',
        recipientName: 'Alex',
        senderName: 'Jordan',
        companyName: 'Acme Co',
        personalMessage: 'Thank you for a great year'
      }
    }
  })
});

const html = await response.json();

The saved record, if any, is readable at:

GET /md/api/Templates
const filter = {
  where: {
    companyId: 'your-company-id',
    code: 'gift-card-for-recipient',
    locale: 'en-US'
  }
};

const filterParam = encodeURIComponent(JSON.stringify(filter));
const response = await fetch(`https://sandbox.custodia-tech.com/md/api/Templates?filter=${filterParam}`, {
  method: 'GET',
  headers: {
    'Authorization': `Bearer ${accessToken}`,
    'x-appid': clientId
  }
});

const templates = await response.json();

Send it again

POST /md/api/Cards/{cardId}/resendGiftEmail

Re-sends the delivery email for an ACTIVE card to the address already on the card, and updates giftNotifiedAt. Use it when a recipient reports the mail never arrived. Requires admin or hr-admin. The personal message from the original order is not repeated, and the address cannot be changed on a resend. A gift sent to the wrong address needs a new order.

Using cURL:

curl -X POST https://sandbox.custodia-tech.com/md/api/Cards/bbbbbbbb-cccc-dddd-eeee-ffffffffffff/resendGiftEmail \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
  -H "x-appid: YOUR_CLIENT_ID"

Using JavaScript (fetch):

const cardId = 'bbbbbbbb-cccc-dddd-eeee-ffffffffffff';

const response = await fetch(`https://sandbox.custodia-tech.com/md/api/Cards/${cardId}/resendGiftEmail`, {
  method: 'POST',
  headers: {
    'Authorization': `Bearer ${accessToken}`,
    'x-appid': clientId
  }
});

const card = await response.json();

The activation link

The link that opens the gift is not returned by any API call. The platform injects it into the email. It is held on the card in a field that is stripped from every API response, for every role.

A recipient gets the link in one of two ways:

  1. The automatic email sent when the card becomes ACTIVE.
  2. POST /md/api/Cards/{cardId}/resendGiftEmail.

Delivering the link through your own channel (an intranet, a letter, a messaging app) requires a platform change to expose it. Raise that with Custodia. The link is issuer-generated and per card.

Endpoint reference

Step Call Role
List brands GET /md/api/CardProducts Any authenticated user in the tenant
Brand terms GET /md/api/CardProducts/{id}/giftDetails Any authenticated user in the tenant
Issue POST /md/api/User/{id}/order-card admin, hr-admin, plus scope f:Card/OrderCards
List / track GET /md/api/Cards Any authenticated user. Recipient details for admin and hr-admin.
Refresh a pending card POST /md/api/Cards/{cardId}/refreshGiftStatus admin, hr-admin, or the card owner
Resend the email POST /md/api/Cards/{cardId}/resendGiftEmail admin, hr-admin
Render the message POST /md/api/Templates/format Any authenticated user in the tenant

Error Responses

All endpoints may return the following authentication and permission errors:

Status Code Description Solution
401 Unauthorized Invalid or missing access token Verify your access token is valid and included in the Authorization header
403 Forbidden Insufficient role or missing f:Card/OrderCards Issue with an admin or hr-admin token that includes DEFAULT and f:Card/OrderCards
404 Not Found Card product, card, or user not found Verify the id and that it belongs to your company

Issue failures

The message on a failed order-card names the problem. A failed order does not consume budget.

Message Meaning
Gift cards can only be issued by an administrator The caller lacks admin or hr-admin.
amount must be one of: … / amount must be between … and … The amount breaks the brand's denomination rule. Re-read brand terms.
recipientEmail is invalid Malformed address.
recipientName is required when sending to a client External gift without firstname or a recipient name.
Unable to issue this gift card, there's no available budget. The gift activity could not be funded from the annual gift budget. The fix is on the budget.
GiftCrowd credentials are invalid or inactive Tenant setup problem. Contact support.
card product is not a GiftCrowd brand The cardProductId is not a gift product.
Order, then confirm: UNACTIVATED means the issuer is still working. Confirm with GET /md/api/Cards or a single refreshGiftStatus before treating the gift as sent.