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.
| Operation | Method | SDK |
|---|---|---|
| Get the Stripe connection | GET | hixel.stripeConnection.get |
| Connect Stripe | PUT | hixel.stripeConnection.connect |
| Enable or disable the Stripe connection | PATCH | hixel.stripeConnection.update |
| Delete the Stripe connection | DELETE | hixel.stripeConnection.delete |
| Store the Stripe webhook secret | PUT | hixel.stripeConnection.setWebhookSecret |
Get the Stripe connection#
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
| Field | Type | Description |
|---|---|---|
id required | string | The id of an environment's Stripe connection (scn_…). |
organization_id required | string | The id of your organization (org_…). |
project_id required | string | The id of a project (proj_…). |
environment_id required | string | The 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 required | string | The key's last four characters. |
stripe_account_id required | string | The Stripe account the key belongs to (acct_…). |
stripe_account_name required | string | null | The Stripe account's name, when it has one. |
enabled required | boolean | false refuses new top-ups; events of earlier ones are still applied. |
has_webhook_secret required | boolean | Whether the webhook endpoint's signing secret is stored; top-ups need it. |
webhook_url required | string | null | Where Stripe sends this connection's events; null when the API's own URL is not configured. |
webhook_events required | array of string | The events to subscribe the webhook endpoint to. |
last_event_at required | string | null | When Stripe last sent the connection an event. |
last_error required | string | null | The last failure with this connection, in the platform's words; never a secret. |
last_error_at required | string | null | When last_error happened. |
key_rejected_at required | string | null | When 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 required | string (date-time) | |
updated_at required | string (date-time) |
Errors
- 400
invalid_request: The request is malformed or fails validation;paramnames the field.environment_required: a project key was sent withoutx-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 themanagementscope.management_scope_required: the environment's key does not have themanagementscope.
- 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-environmentnames 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"const stripeConnection = await hixel.stripeConnection.get();Connect Stripe#
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
| Field | Type | Description |
|---|---|---|
api_key required | string | A 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
| Field | Type | Description |
|---|---|---|
id required | string | The id of an environment's Stripe connection (scn_…). |
organization_id required | string | The id of your organization (org_…). |
project_id required | string | The id of a project (proj_…). |
environment_id required | string | The 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 required | string | The key's last four characters. |
stripe_account_id required | string | The Stripe account the key belongs to (acct_…). |
stripe_account_name required | string | null | The Stripe account's name, when it has one. |
enabled required | boolean | false refuses new top-ups; events of earlier ones are still applied. |
has_webhook_secret required | boolean | Whether the webhook endpoint's signing secret is stored; top-ups need it. |
webhook_url required | string | null | Where Stripe sends this connection's events; null when the API's own URL is not configured. |
webhook_events required | array of string | The events to subscribe the webhook endpoint to. |
last_event_at required | string | null | When Stripe last sent the connection an event. |
last_error required | string | null | The last failure with this connection, in the platform's words; never a secret. |
last_error_at required | string | null | When last_error happened. |
key_rejected_at required | string | null | When 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 required | string (date-time) | |
updated_at required | string (date-time) |
Errors
- 400
invalid_parameter,stripe_refused: The request is malformed or fails validation;paramnames 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: anIdempotency-Keyis 1 to 255 characters of visible ASCII.environment_required: a project key was sent withoutx-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 themanagementscope.management_scope_required: the environment's key does not have themanagementscope.role_not_allowed: the project key'smemberrole does not allow this; it takesadmin.
- 404
environment_not_found:x-hixel-environmentnames 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-…"
}'const stripeConnection = await hixel.stripeConnection.connect({
api_key: "sk-…",
});Enable or disable the Stripe connection#
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
| Field | Type | Description |
|---|---|---|
enabled required | boolean | false refuses new top-ups; events of earlier ones are still applied. |
Response 200: StripeConnection
| Field | Type | Description |
|---|---|---|
id required | string | The id of an environment's Stripe connection (scn_…). |
organization_id required | string | The id of your organization (org_…). |
project_id required | string | The id of a project (proj_…). |
environment_id required | string | The 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 required | string | The key's last four characters. |
stripe_account_id required | string | The Stripe account the key belongs to (acct_…). |
stripe_account_name required | string | null | The Stripe account's name, when it has one. |
enabled required | boolean | false refuses new top-ups; events of earlier ones are still applied. |
has_webhook_secret required | boolean | Whether the webhook endpoint's signing secret is stored; top-ups need it. |
webhook_url required | string | null | Where Stripe sends this connection's events; null when the API's own URL is not configured. |
webhook_events required | array of string | The events to subscribe the webhook endpoint to. |
last_event_at required | string | null | When Stripe last sent the connection an event. |
last_error required | string | null | The last failure with this connection, in the platform's words; never a secret. |
last_error_at required | string | null | When last_error happened. |
key_rejected_at required | string | null | When 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 required | string (date-time) | |
updated_at required | string (date-time) |
Errors
- 400
invalid_request: The request is malformed or fails validation;paramnames the field.invalid_idempotency_key: anIdempotency-Keyis 1 to 255 characters of visible ASCII.environment_required: a project key was sent withoutx-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 themanagementscope.management_scope_required: the environment's key does not have themanagementscope.role_not_allowed: the project key'smemberrole does not allow this; it takesadmin.
- 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-environmentnames 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
}'const stripeConnection = await hixel.stripeConnection.update({
enabled: true,
});Delete the Stripe connection#
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
| Name | In | Type | Description |
|---|---|---|---|
confirm_recent_payments | query | boolean | true 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;paramnames the field.invalid_idempotency_key: anIdempotency-Keyis 1 to 255 characters of visible ASCII.environment_required: a project key was sent withoutx-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 themanagementscope.management_scope_required: the environment's key does not have themanagementscope.role_not_allowed: the project key'smemberrole does not allow this; it takesadmin.
- 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-environmentnames 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"await hixel.stripeConnection.delete();Store the Stripe webhook secret#
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
| Field | Type | Description |
|---|---|---|
webhook_secret required | string | The signing secret (whsec_…) of the Stripe webhook endpoint you created for webhook_url; never returned. |
Response 200: StripeConnection
| Field | Type | Description |
|---|---|---|
id required | string | The id of an environment's Stripe connection (scn_…). |
organization_id required | string | The id of your organization (org_…). |
project_id required | string | The id of a project (proj_…). |
environment_id required | string | The 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 required | string | The key's last four characters. |
stripe_account_id required | string | The Stripe account the key belongs to (acct_…). |
stripe_account_name required | string | null | The Stripe account's name, when it has one. |
enabled required | boolean | false refuses new top-ups; events of earlier ones are still applied. |
has_webhook_secret required | boolean | Whether the webhook endpoint's signing secret is stored; top-ups need it. |
webhook_url required | string | null | Where Stripe sends this connection's events; null when the API's own URL is not configured. |
webhook_events required | array of string | The events to subscribe the webhook endpoint to. |
last_event_at required | string | null | When Stripe last sent the connection an event. |
last_error required | string | null | The last failure with this connection, in the platform's words; never a secret. |
last_error_at required | string | null | When last_error happened. |
key_rejected_at required | string | null | When 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 required | string (date-time) | |
updated_at required | string (date-time) |
Errors
- 400
invalid_parameter: The request is malformed or fails validation;paramnames the field.invalid_idempotency_key: anIdempotency-Keyis 1 to 255 characters of visible ASCII.environment_required: a project key was sent withoutx-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 themanagementscope.management_scope_required: the environment's key does not have themanagementscope.role_not_allowed: the project key'smemberrole does not allow this; it takesadmin.
- 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-environmentnames 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_…"
}'const stripeConnection = await hixel.stripeConnection.setWebhookSecret({
webhook_secret: "whsec_…",
});