Overview
Adds cards to the active buy cart. The v3.1 endpoint supports adding multiple cards in a single request and handles partial fulfillment gracefully.
Use the v3.1 base path for this endpoint: https://sandbox-api.cardcash.com/v3.1/carts/:cartId/cards
Request
Path Parameters
| Parameter | Type | Required | Description |
|---|
cartId | string | Yes | Cart UUID from create cart |
Body Parameters
| Parameter | Type | Required | Description |
|---|
cards | array | Yes | Array of cards to add |
Card Object
| Field | Type | Required | Description |
|---|
merchantId | integer | Yes | Merchant ID |
faceValue | number | Yes | Face value of the card |
percentOff | number | Yes | Discount percentage |
type | string | Yes | Card type (ecode, physical, newEcodeB2B) |
quantity | integer | Yes | Number of cards to add |
curl -X POST https://sandbox-api.cardcash.com/v3.1/carts/CART_ID/cards \
-H "x-cc-app: YOUR_APP_ID" \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"cards": [
{
"merchantId": 123,
"faceValue": 50,
"percentOff": 8.5,
"type": "ecode",
"quantity": 3
},
{
"merchantId": 123,
"faceValue": 100,
"percentOff": 7.0,
"type": "ecode",
"quantity": 1
}
]
}'
Most endpoints use /v3/, but this endpoint uses /v3.1/. The only difference is the multi-card support in the request body.
Response (Full Success)
Status: 201 Created
{
"cart": {
"cartId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"cards": [
{
"id": "card-uuid-001",
"merchant": 123,
"merchantName": "Target",
"merchantImage": "https://...",
"balance": 50.00,
"cost": 45.75,
"quantity": 3,
"percentOff": 8.5,
"type": "ecode",
"isLowRisk": true
},
{
"id": "card-uuid-002",
"merchant": 123,
"merchantName": "Target",
"merchantImage": "https://...",
"balance": 100.00,
"cost": 93.00,
"quantity": 1,
"percentOff": 7.0,
"type": "ecode",
"isLowRisk": true
}
],
"couponData": null
}
}
Response (Partial Success)
If some cards cannot be fulfilled (insufficient inventory), the API adds what it can and reports the details:
{
"cart": {
"cartId": "...",
"cards": [...]
},
"requested": 4,
"added": 3,
"details": [
{
"merchantId": 123,
"value": 50,
"type": "ecode",
"percentOff": 8.5,
"requested": 3,
"added": 3
},
{
"merchantId": 123,
"value": 100,
"type": "ecode",
"percentOff": 7.0,
"requested": 1,
"added": 0,
"reason": "Error, insufficient inventory"
}
]
}
Error Response
{
"message": ["Error, insufficient inventory"]
}
Notes
- Inventory is reserved when added to cart (other buyers cannot purchase the same cards)
- If
requested > added in the response, check the details array for per-card status
- Cards remain in the cart until removed, checked out, or the cart expires