Skip to main content
POST
/
gift-cards
Store gift card
using RestSharp;


var options = new RestClientOptions("https://api.sandbox.{id}.gr4vy.app/gift-cards");
var client = new RestClient(options);
var request = new RestRequest("");
request.AddHeader("Authorization", "Bearer <token>");
request.AddJsonBody("{\n  \"number\": \"4123455541234561234\",\n  \"pin\": \"1234\"\n}", false);
var response = await client.PostAsync(request);

Console.WriteLine("{0}", response.Content);
package main

import (
"fmt"
"strings"
"net/http"
"io"
)

func main() {

url := "https://api.sandbox.{id}.gr4vy.app/gift-cards"

payload := strings.NewReader("{\n \"number\": \"4123455541234561234\",\n \"pin\": \"1234\"\n}")

req, _ := http.NewRequest("POST", url, payload)

req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")

res, _ := http.DefaultClient.Do(req)

defer res.Body.Close()
body, _ := io.ReadAll(res.Body)

fmt.Println(string(body))

}
HttpResponse<String> response = Unirest.post("https://api.sandbox.{id}.gr4vy.app/gift-cards")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"number\": \"4123455541234561234\",\n \"pin\": \"1234\"\n}")
.asString();
<?php

$curl = curl_init();

curl_setopt_array($curl, [
CURLOPT_URL => "https://api.sandbox.{id}.gr4vy.app/gift-cards",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'number' => '4123455541234561234',
'pin' => '1234'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
import requests

url = "https://api.sandbox.{id}.gr4vy.app/gift-cards"

payload = {
"number": "4123455541234561234",
"pin": "1234"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({number: '4123455541234561234', pin: '1234'})
};

fetch('https://api.sandbox.{id}.gr4vy.app/gift-cards', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));
curl --request POST \
--url https://api.sandbox.{id}.gr4vy.app/gift-cards \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"number": "4123455541234561234",
"pin": "1234"
}
'
{
  "type": "gift-card",
  "id": "e6cdf979-87e2-4796-8ff6-9784d5aed893",
  "merchant_account_id": "default",
  "service": {
    "type": "gift-card-service",
    "id": "6c020bf3-179b-4f4f-858d-84e39e196e0f",
    "merchant_account_id": "default",
    "gift_card_service_definition_id": "qwikcilver-gift-card",
    "display_name": "Qwikcilver UK",
    "active": true,
    "fields": [
      {
        "key": "secret_key",
        "value": "sk_test_26PHem9AhJZvU623DfE1x4sd"
      }
    ],
    "created_at": "2012-12-12T10:53:43+00:00",
    "updated_at": "2012-12-12T10:53:43+00:00"
  },
  "bin": "412345",
  "sub_bin": "554",
  "last4": "1234",
  "expiration_date": "2013-07-16T19:23:00.000+00:00",
  "buyer": {
    "type": "buyer",
    "id": "fe26475d-ec3e-4884-9553-f7356683f7f9",
    "billing_details": {
      "type": "billing-details",
      "first_name": "John",
      "last_name": "Lunn",
      "email_address": "john@example.com",
      "phone_number": "+1234567890",
      "address": {
        "city": "London",
        "country": "GB",
        "postal_code": "789123",
        "state": "Greater London",
        "state_code": "GB-LND",
        "house_number_or_name": "10",
        "line1": "10 Oxford Street",
        "line2": "New Oxford Court",
        "organization": "Gr4vy"
      },
      "tax_id": {
        "value": "12345678931",
        "kind": "gb.vat"
      }
    },
    "created_at": "2013-07-16T19:23:00.000+00:00",
    "display_name": "John L.",
    "external_identifier": "user-789123",
    "merchant_account_id": "default",
    "updated_at": "2013-07-16T19:23:00.000+00:00",
    "account_number": "1234567"
  },
  "created_at": "2013-07-16T19:23:00.000+00:00",
  "updated_at": "2013-07-16T19:23:00.000+00:00"
}
{
"type": "error",
"code": "bad_request",
"status": 400,
"message": "Missing '****' field",
"details": [
{
"location": "body",
"type": "value_error.missing",
"pointer": "/payment_method/number",
"message": "field required"
}
]
}
{
"type": "error",
"code": "unauthorized",
"status": 401,
"message": "No valid API authentication found",
"details": []
}
{
"type": "error",
"code": "duplicate_record",
"status": 409,
"message": "A duplicate record exists with this external_identifier value",
"details": []
}
{
"type": "error",
"code": "too_many_requests",
"status": 429,
"message": "Too many requests",
"details": []
}
This endpoint requires the gift-cards.write scope.

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Body

application/json

The gift card details to store.

number
string
required

The 16-19 digit number for this gift card.

Required string length: 16 - 19
Pattern: ^[0-9]{16,19}$
Example:

"4123455541234561234"

pin
string
required

The PIN for this gift card.

Example:

"1234"

buyer_id
string<uuid>

The ID of the buyer to associate this gift card to. If this field is provided then the buyer_external_identifier field needs to be unset.

Example:

"fe26475d-ec3e-4884-9553-f7356683f7f9"

buyer_external_identifier
string

The external_identifier of the buyer to associate this gift card to. If this field is provided then the buyer_id field needs to be unset.

Example:

"user-789123"

Response

Returns the stored gift card.

A gift card stored for a buyer, or used in a transaction.

type
enum<string>

The type of this resource.

Available options:
gift-card
Example:

"gift-card"

id
string<uuid>

The ID of this gift card.

Example:

"e6cdf979-87e2-4796-8ff6-9784d5aed893"

merchant_account_id
string

The unique ID for a merchant account.

Example:

"default"

service
A gift card service · object

An configured gift card service.

bin
string

The first 6 digits of the full gift card number.

Example:

"412345"

sub_bin
string

The 3 digits after the bin of the full gift card number.

Example:

"554"

last4
string

The last 4 digits for the gift card.

Example:

"1234"

expiration_date
string<date-time> | null

The date and time when this gift card expires. This is a full date/time and may be more accurate than the actual expiry date received by the gift card service.

Example:

"2013-07-16T19:23:00.000+00:00"

buyer
Buyer · object | null

The optional buyer for which this payment method has been stored.

created_at
string<date-time>

The date and time when this gift card was created in our system.

Example:

"2013-07-16T19:23:00.000+00:00"

updated_at
string<date-time>

The date and time when this gift card was last updated in our system.

Example:

"2013-07-16T19:23:00.000+00:00"