Skip to content

Payment Methods API ​

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 ​

shell
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:

json
{
  "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 ​

FieldDescription
idThe card's ID, which you pass as <CardId> to the endpoints below.
brandThe card brand, such as visa or mastercard.
last4The last four digits of the card number.
exp_monthThe expiry month.
exp_yearThe expiry year.
defaulttrue for the default card.
backuptrue 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.

shell
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:

json
{
  "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.

json
{
  "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.

shell
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.

shell
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 ​

StatusWhen
404The account has no saved card with that <CardId>.
422The 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.