Payment Methods API
AI agents and LLMs: before exploring further, fetch the full index of Typesense documentation with descriptions at https://typesense.org/docs/llms.txt.
These endpoints list the cards saved on your account and let you choose which card is charged. Every invoice is charged to the default card, and to the backup card if the default card is declined.
To add a card, click on "Add Payment Method" on your Account page in Typesense Cloud.
List saved cards
curl -X GET --location "https://cloud.typesense.org/api/v1/account/payment-methods" \
-H "Accept: application/json" \
-H "X-TYPESENSE-CLOUD-MANAGEMENT-API-KEY: YOUR-API-KEY"Response:
{
"payment_methods": [
{
"id": 1520637891,
"brand": "visa",
"last4": "4242",
"exp_month": 12,
"exp_year": 2028,
"default": true,
"backup": false
},
{
"id": 834276150,
"brand": "mastercard",
"last4": "4444",
"exp_month": 6,
"exp_year": 2029,
"default": false,
"backup": true
},
{
"id": 1946032875,
"brand": "amex",
"last4": "8431",
"exp_month": 3,
"exp_year": 2027,
"default": false,
"backup": false
}
]
}The default card is listed first, then the backup card, then any other saved cards.
Response Parameters
| Field | Description |
|---|---|
id | The card's ID, which you pass as <CardId> to the endpoints below. |
brand | The card brand, such as visa or mastercard. |
last4 | The last four digits of the card number. |
exp_month | The expiry month. |
exp_year | The expiry year. |
default | true for the default card. |
backup | true for the backup card. |
A card with default and backup both set to false isn't charged until you make it the default or the backup.
Set default card
This endpoint makes a saved card the default. The previous default stays saved. If the card you chose was the backup, the previous default becomes the backup.
curl -X PUT --location "https://cloud.typesense.org/api/v1/account/payment-methods/<CardId>/default" \
-H "Accept: application/json" \
-H "X-TYPESENSE-CLOUD-MANAGEMENT-API-KEY: YOUR-API-KEY"This endpoint returns the saved cards after the change, in the same format as List saved cards:
{
"payment_methods": [
{
"id": 834276150,
"brand": "mastercard",
"last4": "4444",
"exp_month": 6,
"exp_year": 2029,
"default": true,
"backup": false
},
{
"id": 1520637891,
"brand": "visa",
"last4": "4242",
"exp_month": 12,
"exp_year": 2028,
"default": false,
"backup": true
},
{
"id": 1946032875,
"brand": "amex",
"last4": "8431",
"exp_month": 3,
"exp_year": 2027,
"default": false,
"backup": false
}
]
}Note
If your account has unpaid invoices, they're charged to the new default card right away. When that charge doesn't go through, the response has a warning.
Response Parameters
warning
warning is only present when unpaid invoices couldn't be charged, for example because a card was declined. The card change goes through either way.
{
"payment_methods": [ ... ],
"warning": "The outstanding balance was not charged. You've reached the limit of 5 payment attempts on your default card in 24 hours. You can retry it in 24 hours or reach out to support@typesense.org."
}Set backup card
This endpoint makes a saved card the backup. An account has one backup card at most, so the previous backup stays saved and is no longer charged.
curl -X PUT --location "https://cloud.typesense.org/api/v1/account/payment-methods/<CardId>/backup" \
-H "Accept: application/json" \
-H "X-TYPESENSE-CLOUD-MANAGEMENT-API-KEY: YOUR-API-KEY"This endpoint returns the saved cards after the change, in the same format as List saved cards.
Note
If your account has unpaid invoices, they're charged right away. When that charge doesn't go through, the response has a warning.
Remove saved card
This endpoint removes a saved card from your account. The default card can't be removed, so you want to make another card the default first.
curl -X DELETE --location "https://cloud.typesense.org/api/v1/account/payment-methods/<CardId>" \
-H "Accept: application/json" \
-H "X-TYPESENSE-CLOUD-MANAGEMENT-API-KEY: YOUR-API-KEY"This endpoint returns the saved cards after the removal, in the same format as List saved cards.
Error responses
| Status | When |
|---|---|
404 | The account has no saved card with that <CardId>. |
422 | The change isn't allowed, for example making the default card the backup or removing the default card. |
Permissions
To list saved cards, you need a key with the billing:read capability. To set the default card, set the backup card or remove a saved card, you need payment_methods:manage. See capabilities.
AI agents connected through the Typesense Cloud MCP server need the same permissions to work with saved cards.