POST /gift_requests
Create a new gift request.
Description
This endpoint allows you to create a new gift request for a recipient. The request will be processed and a unique ID will be generated for tracking.
HTTP Request
POST https://api.andopen.com/gift_requests
Request Body
JSON Schema
"data": {
"type": "gift_requests",
"attributes": {
"campaign_id": "string", "format": "uuid"
"first_name": "string",
"last_name": "string",
"email": "string", "format": "email"
}
}
Request Body Parameters
The request body must follow JSON:API specification.
| Parameter | Type | Required | Description |
|---|---|---|---|
data | object | Yes | Root data object |
data.type | string | Yes | Must be "gift_requests" |
data.attributes | object | Yes | Attributes of the gift request |
data.attributes Parameters
| Parameter | Type | Required | Description | Validation |
|---|---|---|---|---|
campaign_id | string | Yes | Unique identifier for the campaign | Must be a valid campaign ID |
first_name | string | Yes | Recipient's first name | 2-255 characters, letters only |
last_name | string | Yes | Recipient's last name | 2-255 characters, letters only |
email | string | No | Recipient's email address | Valid email format |
Responses
🟢 Success Response (201 Created)
{
"data": {
"type": "gift_requests",
"id": "4fb4cb3f-9666-43b5-8884-7f5194483d1a",
"attributes": {
"redemption_url": "https://openai.andopen.co/r/1237676",
"status": "pending",
"created_at": "2025-01-27T10:30:00Z",
"updated_at": "2025-01-27T10:30:00Z"
}
}
}
🔴 Error Response (422 UnprocessableEntity)
{
"errors":
[
{
"status": "422",
"detail": "campaing_id does not exist"
}
],
"jsonapi": {
"version" => "1.0"
}
}
🔴 Error Response (422 Parameter Missing)
{
"errors":
[
{
"status": "422",
"detail": "param is missing or the value is empty or invalid: <parameter>"
}
],
"jsonapi": {
"version" => "1.0"
}
}
Code Examples
- cURL
- Ruby
- JavaScript
- Java
- Python
- PHP
curl -X POST \
-H 'Content-Type: application/vnd.api+json' \
-H 'Authorization: Bearer <api_key>' \
-H 'AndOpen-API-Version: 2025-09' \
-H 'AndOpen-Account: <customer_fqdn>' \
--data '{
"data": {
"type": "gift_requests",
"attributes": {
"campaign_id": "<campaign_id>",
"first_name": "John",
"last_name": "Doe",
"email": "john.doe@example.com"
}
}
}' \
https://api.andopen.co/gift_requests
require 'net/http'
require 'json'
uri = URI('https://api.andopen.co/gift_requests')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
headers = {
'Content-Type' => 'application/vnd.api+json',
'Authorization' => 'Bearer <api_key>',
'AndOpen-API-Version' => '2025-09',
'AndOpen-Account' => '<customer_fqdn>'
}
data = {
data: {
type: 'gift_requests',
attributes: {
campaign_id: '<campaign_id>',
first_name: 'John',
last_name: 'Doe',
email: 'john.doe@example.com'
}
}
}
request = Net::HTTP::Post.new(uri.path, headers)
request.body = data.to_json
response = http.request(request)
puts response.body
const response = await fetch('https://api.andopen.co/gift_requests', {
method: 'POST',
headers: {
'Content-Type': 'application/vnd.api+json',
'Authorization': 'Bearer <api_key>',
'AndOpen-API-Version': '2025-09',
'AndOpen-Account': '<customer_fqdn>'
},
body: JSON.stringify({
data: {
type: 'gift_requests',
attributes: {
campaign_id: '<campaign_id>',
first_name: 'John',
last_name: 'Doe',
email: 'john.doe@example.com'
}
}
})
});
const data = await response.json();
console.log(data);
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
public class GiftRequestExample {
public static void main(String[] args) throws Exception {
String jsonBody = """
{
"data": {
"type": "gift_requests",
"attributes": {
"campaign_id": "<campaign_id>",
"first_name": "John",
"last_name": "Doe",
"email": "john.doe@example.com"
}
}
}
""";
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://api.andopen.co/gift_requests"))
.header("Content-Type", "application/vnd.api+json")
.header("Authorization", "Bearer <api_key>")
.header("AndOpen-API-Version", "2025-09")
.header("AndOpen-Account", "<customer_fqdn>")
.POST(HttpRequest.BodyPublishers.ofString(jsonBody))
.build();
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
}
}
import requests
url = 'https://api.andopen.co/gift_requests'
headers = {
'Content-Type': 'application/vnd.api+json',
'Authorization': 'Bearer <api_key>',
'AndOpen-API-Version': '2025-09',
'AndOpen-Account': '<customer_fqdn>'
}
data = {
'data': {
'type': 'gift_requests',
'attributes': {
'campaign_id': '<campaign_id>',
'first_name': 'John',
'last_name': 'Doe',
'email': 'john.doe@example.com'
}
}
}
response = requests.post(url, headers=headers, json=data)
print(response.json())
<?php
$url = 'https://api.andopen.co/gift_requests';
$data = [
'data' => [
'type' => 'gift_requests',
'attributes' => [
'campaign_id' => '<campaign_id>',
'first_name' => 'John',
'last_name' => 'Doe',
'email' => 'john.doe@example.com'
]
]
];
$headers = [
'Content-Type: application/vnd.api+json',
'Authorization: Bearer <api_key>',
'AndOpen-API-Version: 2025-09',
'AndOpen-Account: <customer_fqdn>'
];
$options = [
'http' => [
'header' => implode("\r\n", $headers),
'method' => 'POST',
'content' => json_encode($data)
]
];
$context = stream_context_create($options);
$result = file_get_contents($url, false, $context);
echo $result;
?>