Skip to main content
POST
/
gift-card-services
New gift card service
using RestSharp;


var options = new RestClientOptions("https://api.sandbox.{id}.gr4vy.app/gift-card-services");
var client = new RestClient(options);
var request = new RestRequest("");
request.AddHeader("Authorization", "Bearer <token>");
request.AddJsonBody("{\n  \"gift_card_service_definition_id\": \"qwikcilver-gift-card\",\n  \"display_name\": \"Qwikcilver UK\",\n  \"fields\": [\n    {\n      \"key\": \"private_key\",\n      \"value\": \"pk_26PHem9AhJZvU623DfE1x4sd\"\n    }\n  ]\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-card-services"

payload := strings.NewReader("{\n \"gift_card_service_definition_id\": \"qwikcilver-gift-card\",\n \"display_name\": \"Qwikcilver UK\",\n \"fields\": [\n {\n \"key\": \"private_key\",\n \"value\": \"pk_26PHem9AhJZvU623DfE1x4sd\"\n }\n ]\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-card-services")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"gift_card_service_definition_id\": \"qwikcilver-gift-card\",\n \"display_name\": \"Qwikcilver UK\",\n \"fields\": [\n {\n \"key\": \"private_key\",\n \"value\": \"pk_26PHem9AhJZvU623DfE1x4sd\"\n }\n ]\n}")
.asString();
<?php

$curl = curl_init();

curl_setopt_array($curl, [
CURLOPT_URL => "https://api.sandbox.{id}.gr4vy.app/gift-card-services",
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([
'gift_card_service_definition_id' => 'qwikcilver-gift-card',
'display_name' => 'Qwikcilver UK',
'fields' => [
[
'key' => 'private_key',
'value' => 'pk_26PHem9AhJZvU623DfE1x4sd'
]
]
]),
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-card-services"

payload = {
"gift_card_service_definition_id": "qwikcilver-gift-card",
"display_name": "Qwikcilver UK",
"fields": [
{
"key": "private_key",
"value": "pk_26PHem9AhJZvU623DfE1x4sd"
}
]
}
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({
gift_card_service_definition_id: 'qwikcilver-gift-card',
display_name: 'Qwikcilver UK',
fields: [{key: 'private_key', value: 'pk_26PHem9AhJZvU623DfE1x4sd'}]
})
};

fetch('https://api.sandbox.{id}.gr4vy.app/gift-card-services', 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-card-services \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"gift_card_service_definition_id": "qwikcilver-gift-card",
"display_name": "Qwikcilver UK",
"fields": [
{
"key": "private_key",
"value": "pk_26PHem9AhJZvU623DfE1x4sd"
}
]
}
'
{
  "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"
}
{
"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": []
}
This endpoint requires the gift-card-services.write scope.

Authorizations

Authorization
string
header
required

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

Body

application/json

Request body for activating a gift card service.

gift_card_service_definition_id
string
required

The ID of the gift card service to use.

Required string length: 1 - 50
Example:

"qwikcilver-gift-card"

display_name
string
required

A custom name for the service. This will be shown in the Admin UI.

Required string length: 1 - 50
Example:

"Qwikcilver UK"

fields
object[]
required

A list of fields, each containing a key-value pair for each field defined by the definition for this gift card service.

active
boolean
default:true

Defines if this service is currently active or not.

Example:

true

Response

Returns the created gift card service.

An configured gift card service.

type
enum<string>

The type of this resource.

Available options:
gift-card-service
Example:

"gift-card-service"

id
string<uuid>

The ID of this gift card service.

Example:

"6c020bf3-179b-4f4f-858d-84e39e196e0f"

merchant_account_id
string

The unique ID for a merchant account.

Example:

"default"

gift_card_service_definition_id
string

The ID of the gift card service definition used to create this service.

Required string length: 1 - 50
Example:

"qwikcilver-gift-card"

display_name
string

The custom name set for this service.

Required string length: 1 - 200
Example:

"Qwikcilver UK"

active
boolean

Defines if this service is currently active or not.

Example:

true

fields
object[]

A list of fields, each containing a key-value pair for each field configured for this gift card service. Fields marked as secret are not returned.

created_at
string<date-time>

The date and time when this service was created.

Example:

"2012-12-12T10:53:43+00:00"

updated_at
string<date-time>

The date and time when this service was last updated.

Example:

"2012-12-12T10:53:43+00:00"