Change a card's daily limit
Raise or lower how much a card can spend per day. Send the card's current status with the new limit.
Use this recipe to raise or lower how much a card can spend per day. You send the card's current status with the new limit.
Who it is for. A consumer app that lets Ada raise her limit for a trip, or an expense platform that caps a driver's daily spend.
Status. Available.
Money example
Ada's card has a 300 USD daily limit and 900 USD on it.
- Ada travels and must pay a 750 USD hotel bill. You raise the limit to 1,000 USD a day.
- Ada pays 750 USD. The card now holds 150 USD.
- After the trip, you set the limit back to 300 USD a day.
PATCH /v1/cards/{card_id}/update sets the status and the limit in one body. An update without limit saves the limit as 0. In live, the card then declines every payment. In sandbox, 0 means no limit, so the card loses its cap. Always send the current status and the intended limit.
Before you start
- The card is not
blocked. - If your API key is scoped, it holds
card:freezeorcard:terminate.
Find out what is required
curl --request GET \
--url https://api.gravv.xyz/v1/cards/a14ec356-f33d-4384-ba68-4d9bfa19765b \
--header 'Api-Key: <API_KEY>'
const response = await fetch("https://api.gravv.xyz/v1/cards/a14ec356-f33d-4384-ba68-4d9bfa19765b", {
method: "GET",
headers: {
"Api-Key": process.env.GRAVV_API_KEY,
},
});
console.log(response.status, await response.json());
import os
import requests
response = requests.get(
"https://api.gravv.xyz/v1/cards/a14ec356-f33d-4384-ba68-4d9bfa19765b",
headers={
"Api-Key": os.environ["GRAVV_API_KEY"],
},
)
print(response.status_code, response.json())
Read status, which you send back unchanged. Read spending_controls.daily_transaction_limit, which is the current limit in whole dollars.
Steps
1. Raise the limit
This route takes no Idempotency-Key.
curl --request PATCH \
--url https://api.gravv.xyz/v1/cards/a14ec356-f33d-4384-ba68-4d9bfa19765b/update \
--header 'Api-Key: <API_KEY>' \
--header 'Content-Type: application/json' \
--data '
{
"status": "active",
"limit": 1000
}
'
const response = await fetch("https://api.gravv.xyz/v1/cards/a14ec356-f33d-4384-ba68-4d9bfa19765b/update", {
method: "PATCH",
headers: {
"Api-Key": process.env.GRAVV_API_KEY,
"Content-Type": "application/json",
},
body: JSON.stringify({
"status": "active",
"limit": 1000
}),
});
console.log(response.status, await response.json());
import os
import requests
response = requests.patch(
"https://api.gravv.xyz/v1/cards/a14ec356-f33d-4384-ba68-4d9bfa19765b/update",
headers={
"Api-Key": os.environ["GRAVV_API_KEY"],
"Content-Type": "application/json",
},
json={
"status": "active",
"limit": 1000,
},
)
print(response.status_code, response.json())
The response is the whole card, with spending_controls.daily_transaction_limit 1000.
limitis a whole number of dollars per day, sent as an integer such as1000.- In live, the limit counts over a rolling 24 hours. In sandbox, it applies to each payment and to the day.
2. Set it back
curl --request PATCH \
--url https://api.gravv.xyz/v1/cards/a14ec356-f33d-4384-ba68-4d9bfa19765b/update \
--header 'Api-Key: <API_KEY>' \
--header 'Content-Type: application/json' \
--data '
{
"status": "active",
"limit": 300
}
'
const response = await fetch("https://api.gravv.xyz/v1/cards/a14ec356-f33d-4384-ba68-4d9bfa19765b/update", {
method: "PATCH",
headers: {
"Api-Key": process.env.GRAVV_API_KEY,
"Content-Type": "application/json",
},
body: JSON.stringify({
"status": "active",
"limit": 300
}),
});
console.log(response.status, await response.json());
import os
import requests
response = requests.patch(
"https://api.gravv.xyz/v1/cards/a14ec356-f33d-4384-ba68-4d9bfa19765b/update",
headers={
"Api-Key": os.environ["GRAVV_API_KEY"],
"Content-Type": "application/json",
},
json={
"status": "active",
"limit": 300,
},
)
print(response.status_code, response.json())
What can go wrong
| Response | Why | Fix |
|---|---|---|
| Every payment declines after a status change (live) | You sent the update without limit |
Send {"status": "<current>", "limit": <intended>} now |
| The card spends without a cap (sandbox) | You sent the update without limit, and 0 means no limit in sandbox |
Send {"status": "<current>", "limit": <intended>} now |
400 status is required |
You sent only limit, or left out Content-Type: application/json |
Send both fields with the header |
400 json: cannot unmarshal number 1000.5 into Go struct field Body.limit of type int |
The limit is a decimal or a string | Send a whole number |
400 unexpected EOF |
The JSON is malformed | Send valid JSON |
400 card is blocked and cannot be updated |
The card is blocked | Issue a new card |
400 invalid status selected |
The status is not active, freeze or blocked |
Use one of those three |
400 failed to update card status |
The card program refused the update | Retry, then read the card back |
400 card status changed concurrently, please retry |
Two updates ran at the same time | Retry |
Webhooks you will receive
Gravv sends no webhook for a limit-only change.
Testing in sandbox
Run the steps on a sandbox card and read the limit back with GET /v1/cards/{card_id}. You cannot make a card spend through the API in sandbox today, so you cannot produce a limit decline.