Documentation menu

Stripe connection

The calling key's environment's connection to your own Stripe account.

customers pay top-ups through Stripe Checkout on it, and auto-refills charge their saved payment method. A wallet is credited when Stripe's own API says a payment succeeded, and credit is taken back on a refund or a dispute.

OperationMethodSDK
Get the Stripe connectionGEThixel.stripeConnection.get
Connect StripePUThixel.stripeConnection.connect
Enable or disable the Stripe connectionPATCHhixel.stripeConnection.update
Delete the Stripe connectionDELETEhixel.stripeConnection.delete
Store the Stripe webhook secretPUThixel.stripeConnection.setWebhookSecret

Get the Stripe connection#

GET/v1/stripe_connectionhixel.stripeConnection.get

The environment's Stripe connection; not_found without one.

Takes an environment key with the management scope, or a project key with the member role or higher, naming the environment in x-hixel-environment.

Response 200: StripeConnection

FieldTypeDescription
id requiredstringThe id of an environment's Stripe connection (scn_…).
organization_id requiredstringThe id of your organization (org_…).
project_id requiredstringThe id of a project (proj_…).
environment_id requiredstringThe id of an environment (env_…).
mode required"live" | "test"The key's, which is always the environment's: live in Production, test elsewhere.
key_kind required"restricted" | "secret"A restricted key (rk_…, recommended) or a standard secret key (sk_…).
key_last_four requiredstringThe key's last four characters.
stripe_account_id requiredstringThe Stripe account the key belongs to (acct_…).
stripe_account_name requiredstring | nullThe Stripe account's name, when it has one.
enabled requiredbooleanfalse refuses new top-ups; events of earlier ones are still applied.
has_webhook_secret requiredbooleanWhether the webhook endpoint's signing secret is stored; top-ups need it.
webhook_url requiredstring | nullWhere Stripe sends this connection's events; null when the API's own URL is not configured.
webhook_events requiredarray of stringThe events to subscribe the webhook endpoint to.
last_event_at requiredstring | nullWhen Stripe last sent the connection an event.
last_error requiredstring | nullThe last failure with this connection, in the platform's words; never a secret.
last_error_at requiredstring | nullWhen last_error happened.
key_rejected_at requiredstring | nullWhen Stripe refused the key (401 or 403: revoked, or a permission removed); null while it works. Until the key is replaced, the scheduled run re-reads none of the connection's payments.
created_at requiredstring (date-time)
updated_at requiredstring (date-time)

Errors

  • 400
    • invalid_request: The request is malformed or fails validation; param names the field.
    • environment_required: a project key was sent without x-hixel-environment.
  • 401 api_key_required, invalid_api_key, expired_api_key: no key was sent; the key is unknown or revoked, or its project or environment is archived; or it has expired.
  • 403
    • key_inactive: the key was revoked or expired while the request ran, or an environment's key lost the management scope.
    • management_scope_required: the environment's key does not have the management scope.
  • 404
    • stripe_connection_not_found: The resource does not exist in the key's environment; a resource outside it reads the same.
    • environment_not_found: x-hixel-environment names an environment outside the project key's project, an archived one, or another than the environment key's own.
  • 500 internal: an unexpected failure on the platform's side (internal_error); the details are logged, never returned.
  • 503 database_unavailable: A dependency, such as the database or Stripe, cannot be reached; retry later.
curl "https://api.hixel.dev/v1/stripe_connection" \
  -H "Authorization: Bearer $HIXEL_API_KEY"

Connect Stripe#

PUT/v1/stripe_connectionhixel.stripeConnection.connect

Connects the environment to your Stripe account with api_key, or replaces the key of its connection (with a key of the same account). Then create a webhook endpoint in Stripe for webhook_url, subscribed to webhook_events, and store its signing secret with PUT /v1/stripe_connection/webhook_secret: top-ups need it.

Takes an environment key with the management scope, or a project key with the admin role, naming the environment in x-hixel-environment. Accepts an Idempotency-Key header: a retry with the same key runs once.

Request body: ConnectStripeBody

FieldTypeDescription
api_key requiredstringA Stripe restricted key (rk_…, recommended) or secret key (sk_…) of the environment's mode: live in Production, test elsewhere. Checked by one read from Stripe before it is stored; never returned.

Response 200: StripeConnection

FieldTypeDescription
id requiredstringThe id of an environment's Stripe connection (scn_…).
organization_id requiredstringThe id of your organization (org_…).
project_id requiredstringThe id of a project (proj_…).
environment_id requiredstringThe id of an environment (env_…).
mode required"live" | "test"The key's, which is always the environment's: live in Production, test elsewhere.
key_kind required"restricted" | "secret"A restricted key (rk_…, recommended) or a standard secret key (sk_…).
key_last_four requiredstringThe key's last four characters.
stripe_account_id requiredstringThe Stripe account the key belongs to (acct_…).
stripe_account_name requiredstring | nullThe Stripe account's name, when it has one.
enabled requiredbooleanfalse refuses new top-ups; events of earlier ones are still applied.
has_webhook_secret requiredbooleanWhether the webhook endpoint's signing secret is stored; top-ups need it.
webhook_url requiredstring | nullWhere Stripe sends this connection's events; null when the API's own URL is not configured.
webhook_events requiredarray of stringThe events to subscribe the webhook endpoint to.
last_event_at requiredstring | nullWhen Stripe last sent the connection an event.
last_error requiredstring | nullThe last failure with this connection, in the platform's words; never a secret.
last_error_at requiredstring | nullWhen last_error happened.
key_rejected_at requiredstring | nullWhen Stripe refused the key (401 or 403: revoked, or a permission removed); null while it works. Until the key is replaced, the scheduled run re-reads none of the connection's payments.
created_at requiredstring (date-time)
updated_at requiredstring (date-time)

Errors

  • 400
    • invalid_parameter, stripe_refused: The request is malformed or fails validation; param names the field.
    • stripe_mode_mismatch: A live environment takes only a live Stripe key (rk_live_ or sk_live_), and a test environment only a test key (rk_test_ or sk_test_).
    • invalid_idempotency_key: an Idempotency-Key is 1 to 255 characters of visible ASCII.
    • environment_required: a project key was sent without x-hixel-environment.
    • invalid_payload, malformed_body, body_too_large: the request's path, query or body does not match its schema, or the body is not JSON or is over 1 MiB.
  • 401 api_key_required, invalid_api_key, expired_api_key: no key was sent; the key is unknown or revoked, or its project or environment is archived; or it has expired.
  • 403
    • key_inactive: the key was revoked or expired while the request ran, or an environment's key lost the management scope.
    • management_scope_required: the environment's key does not have the management scope.
    • role_not_allowed: the project key's member role does not allow this; it takes admin.
  • 404 environment_not_found: x-hixel-environment names an environment outside the project key's project, an archived one, or another than the environment key's own.
  • 409
    • project_archived: This project is archived.
    • environment_archived: This environment is archived.
    • stripe_account_changed: This key belongs to another Stripe account than the connection's. Delete the connection and connect again to change accounts.
    • idempotency_key_reused, idempotency_key_in_use: the key was used for another request (method, path or body), or the first request with it is still running.
  • 500 internal: an unexpected failure on the platform's side (internal_error); the details are logged, never returned.
  • 503
    • database_unavailable, stripe_unavailable: A dependency, such as the database or Stripe, cannot be reached; retry later.
    • database_unavailable: the stored response to the key could not be read or written; retry later.
    • database_unavailable: A dependency, such as the database or Stripe, cannot be reached; retry later.
curl -X PUT "https://api.hixel.dev/v1/stripe_connection" \
  -H "Authorization: Bearer $HIXEL_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "api_key": "sk-…"
  }'

Enable or disable the Stripe connection#

PATCH/v1/stripe_connectionhixel.stripeConnection.update

A disabled connection refuses new top-ups; events of earlier ones are still applied.

Takes an environment key with the management scope, or a project key with the admin role, naming the environment in x-hixel-environment. Accepts an Idempotency-Key header: a retry with the same key runs once.

Request body: UpdateStripeConnectionBody

FieldTypeDescription
enabled requiredbooleanfalse refuses new top-ups; events of earlier ones are still applied.

Response 200: StripeConnection

FieldTypeDescription
id requiredstringThe id of an environment's Stripe connection (scn_…).
organization_id requiredstringThe id of your organization (org_…).
project_id requiredstringThe id of a project (proj_…).
environment_id requiredstringThe id of an environment (env_…).
mode required"live" | "test"The key's, which is always the environment's: live in Production, test elsewhere.
key_kind required"restricted" | "secret"A restricted key (rk_…, recommended) or a standard secret key (sk_…).
key_last_four requiredstringThe key's last four characters.
stripe_account_id requiredstringThe Stripe account the key belongs to (acct_…).
stripe_account_name requiredstring | nullThe Stripe account's name, when it has one.
enabled requiredbooleanfalse refuses new top-ups; events of earlier ones are still applied.
has_webhook_secret requiredbooleanWhether the webhook endpoint's signing secret is stored; top-ups need it.
webhook_url requiredstring | nullWhere Stripe sends this connection's events; null when the API's own URL is not configured.
webhook_events requiredarray of stringThe events to subscribe the webhook endpoint to.
last_event_at requiredstring | nullWhen Stripe last sent the connection an event.
last_error requiredstring | nullThe last failure with this connection, in the platform's words; never a secret.
last_error_at requiredstring | nullWhen last_error happened.
key_rejected_at requiredstring | nullWhen Stripe refused the key (401 or 403: revoked, or a permission removed); null while it works. Until the key is replaced, the scheduled run re-reads none of the connection's payments.
created_at requiredstring (date-time)
updated_at requiredstring (date-time)

Errors

  • 400
    • invalid_request: The request is malformed or fails validation; param names the field.
    • invalid_idempotency_key: an Idempotency-Key is 1 to 255 characters of visible ASCII.
    • environment_required: a project key was sent without x-hixel-environment.
    • invalid_payload, malformed_body, body_too_large: the request's path, query or body does not match its schema, or the body is not JSON or is over 1 MiB.
  • 401 api_key_required, invalid_api_key, expired_api_key: no key was sent; the key is unknown or revoked, or its project or environment is archived; or it has expired.
  • 403
    • key_inactive: the key was revoked or expired while the request ran, or an environment's key lost the management scope.
    • management_scope_required: the environment's key does not have the management scope.
    • role_not_allowed: the project key's member role does not allow this; it takes admin.
  • 404
    • stripe_connection_not_found: The resource does not exist in the key's environment; a resource outside it reads the same.
    • environment_not_found: x-hixel-environment names an environment outside the project key's project, an archived one, or another than the environment key's own.
  • 409
    • project_archived: This project is archived.
    • environment_archived: This environment is archived.
    • idempotency_key_reused, idempotency_key_in_use: the key was used for another request (method, path or body), or the first request with it is still running.
  • 500 internal: an unexpected failure on the platform's side (internal_error); the details are logged, never returned.
  • 503
    • database_unavailable: A dependency, such as the database or Stripe, cannot be reached; retry later.
    • database_unavailable: the stored response to the key could not be read or written; retry later.
curl -X PATCH "https://api.hixel.dev/v1/stripe_connection" \
  -H "Authorization: Bearer $HIXEL_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "enabled": true
  }'

Delete the Stripe connection#

DELETE/v1/stripe_connectionhixel.stripeConnection.delete

Deletes the connection, once none of its top-ups or auto-refills may still be paid (stripe_connection_in_use: disable it first, and delete it once they have ended). With payments credited within the dispute window (120 days) it needs confirm_recent_payments=true; the stripe_connection_has_recent_payments failure's message says how many and when the latest was credited. Answers 204 with no body.

Takes an environment key with the management scope, or a project key with the admin role, naming the environment in x-hixel-environment. Accepts an Idempotency-Key header: a retry with the same key runs once.

Parameters

NameInTypeDescription
confirm_recent_paymentsquerybooleantrue deletes it even with payments credited within the last 120 days, whose refunds and disputes are then no longer taken from the wallets.

Response 204

No body.

Errors

  • 400
    • invalid_request: The request is malformed or fails validation; param names the field.
    • invalid_idempotency_key: an Idempotency-Key is 1 to 255 characters of visible ASCII.
    • environment_required: a project key was sent without x-hixel-environment.
    • invalid_query: the request's path, query or body does not match its schema, or the body is not JSON or is over 1 MiB.
  • 401 api_key_required, invalid_api_key, expired_api_key: no key was sent; the key is unknown or revoked, or its project or environment is archived; or it has expired.
  • 403
    • key_inactive: the key was revoked or expired while the request ran, or an environment's key lost the management scope.
    • management_scope_required: the environment's key does not have the management scope.
    • role_not_allowed: the project key's member role does not allow this; it takes admin.
  • 404
    • stripe_connection_not_found: The resource does not exist in the key's environment; a resource outside it reads the same.
    • environment_not_found: x-hixel-environment names an environment outside the project key's project, an archived one, or another than the environment key's own.
  • 409
    • project_archived: This project is archived.
    • environment_archived: This environment is archived.
    • stripe_connection_in_use: Top-ups or auto-refills on this connection may still be paid. Disable the connection, and delete it once they have ended.
    • stripe_connection_has_recent_payments: Payments on this Stripe account were credited within the last 120 days. Once the connection is deleted, their refunds and disputes are no longer taken from the wallets unless the same Stripe account is connected again. Confirm to delete it anyway.
    • idempotency_key_reused, idempotency_key_in_use: the key was used for another request (method, path or body), or the first request with it is still running.
  • 500 internal: an unexpected failure on the platform's side (internal_error); the details are logged, never returned.
  • 503
    • database_unavailable: A dependency, such as the database or Stripe, cannot be reached; retry later.
    • database_unavailable: the stored response to the key could not be read or written; retry later.
curl -X DELETE "https://api.hixel.dev/v1/stripe_connection" \
  -H "Authorization: Bearer $HIXEL_API_KEY"

Store the Stripe webhook secret#

PUT/v1/stripe_connection/webhook_secrethixel.stripeConnection.setWebhookSecret

Stores the signing secret of the Stripe webhook endpoint that sends the connection's events.

Takes an environment key with the management scope, or a project key with the admin role, naming the environment in x-hixel-environment. Accepts an Idempotency-Key header: a retry with the same key runs once.

Request body: StripeWebhookSecretBody

FieldTypeDescription
webhook_secret requiredstringThe signing secret (whsec_…) of the Stripe webhook endpoint you created for webhook_url; never returned.

Response 200: StripeConnection

FieldTypeDescription
id requiredstringThe id of an environment's Stripe connection (scn_…).
organization_id requiredstringThe id of your organization (org_…).
project_id requiredstringThe id of a project (proj_…).
environment_id requiredstringThe id of an environment (env_…).
mode required"live" | "test"The key's, which is always the environment's: live in Production, test elsewhere.
key_kind required"restricted" | "secret"A restricted key (rk_…, recommended) or a standard secret key (sk_…).
key_last_four requiredstringThe key's last four characters.
stripe_account_id requiredstringThe Stripe account the key belongs to (acct_…).
stripe_account_name requiredstring | nullThe Stripe account's name, when it has one.
enabled requiredbooleanfalse refuses new top-ups; events of earlier ones are still applied.
has_webhook_secret requiredbooleanWhether the webhook endpoint's signing secret is stored; top-ups need it.
webhook_url requiredstring | nullWhere Stripe sends this connection's events; null when the API's own URL is not configured.
webhook_events requiredarray of stringThe events to subscribe the webhook endpoint to.
last_event_at requiredstring | nullWhen Stripe last sent the connection an event.
last_error requiredstring | nullThe last failure with this connection, in the platform's words; never a secret.
last_error_at requiredstring | nullWhen last_error happened.
key_rejected_at requiredstring | nullWhen Stripe refused the key (401 or 403: revoked, or a permission removed); null while it works. Until the key is replaced, the scheduled run re-reads none of the connection's payments.
created_at requiredstring (date-time)
updated_at requiredstring (date-time)

Errors

  • 400
    • invalid_parameter: The request is malformed or fails validation; param names the field.
    • invalid_idempotency_key: an Idempotency-Key is 1 to 255 characters of visible ASCII.
    • environment_required: a project key was sent without x-hixel-environment.
    • invalid_payload, malformed_body, body_too_large: the request's path, query or body does not match its schema, or the body is not JSON or is over 1 MiB.
  • 401 api_key_required, invalid_api_key, expired_api_key: no key was sent; the key is unknown or revoked, or its project or environment is archived; or it has expired.
  • 403
    • key_inactive: the key was revoked or expired while the request ran, or an environment's key lost the management scope.
    • management_scope_required: the environment's key does not have the management scope.
    • role_not_allowed: the project key's member role does not allow this; it takes admin.
  • 404
    • stripe_connection_not_found: The resource does not exist in the key's environment; a resource outside it reads the same.
    • environment_not_found: x-hixel-environment names an environment outside the project key's project, an archived one, or another than the environment key's own.
  • 409
    • project_archived: This project is archived.
    • environment_archived: This environment is archived.
    • idempotency_key_reused, idempotency_key_in_use: the key was used for another request (method, path or body), or the first request with it is still running.
  • 500 internal: an unexpected failure on the platform's side (internal_error); the details are logged, never returned.
  • 503
    • database_unavailable: A dependency, such as the database or Stripe, cannot be reached; retry later.
    • database_unavailable: the stored response to the key could not be read or written; retry later.
curl -X PUT "https://api.hixel.dev/v1/stripe_connection/webhook_secret" \
  -H "Authorization: Bearer $HIXEL_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "webhook_secret": "whsec_…"
  }'