API reference

Customer Sessions

A Customer Session allows you to grant Stripe's frontend SDKs (like Stripe.js) client-side access control over a Customer. Related guides: Customer Session with the Payment Element, Customer Session with the Pricing Table, Customer Session with the Buy Button.

Knox answers these operations with the same requests and responses as Stripe's API. Authenticate with your secret key, Authorization: Bearer sk_test_..., from your server, and send form-encoded bodies. Test mode only: live processing is currently disabled.

Base URL
https://api.knoxapi.com

Create a Customer Session

POST/v1/customer_sessions

Creates a Customer Session object that includes a single-use client secret that you can use on your front-end to grant client-side API access for certain customer resources.

Body parameters

  • componentsobjectRequired

    Configuration for each component. At least 1 component must be enabled.

    Show 7 child parameters
    • active_entitlementsobject
      Show 1 child parameter
      • enabledbooleanRequired
    • buy_buttonobject
      Show 1 child parameter
      • enabledbooleanRequired
    • customer_portalobject
      Show 1 child parameter
      • enabledbooleanRequired
    • customer_sheetobject
      Show 2 child parameters
      • enabledbooleanRequired
      • featuresobject

        Child parameters are listed in the OpenAPI document.

    • mobile_payment_elementobject
      Show 2 child parameters
      • enabledbooleanRequired
      • featuresobject

        Child parameters are listed in the OpenAPI document.

    • payment_elementobject
      Show 2 child parameters
      • enabledbooleanRequired
      • featuresobject

        Child parameters are listed in the OpenAPI document.

    • pricing_tableobject
      Show 1 child parameter
      • enabledbooleanRequired
  • customerstring

    The ID of an existing customer for which to create the Customer Session.

  • customer_accountstring

    The ID of an existing Account for which to create the Customer Session.

  • expandarray of strings

    Specifies which fields in the response should be expanded.

Returns

The customer_session object.

POST /v1/customer_sessions
curl https://api.knoxapi.com/v1/customer_sessions \
  -H "Authorization: Bearer $KNOX_SECRET_KEY" \
  -d components=
Response
{
  "client_secret": "cuss_secret_QXhWeUEtZoDV8FHnNbPiBHmAkXKnqYLGMGq7LLf8ODSQ8gL",
  "components": {
    "buy_button": {
      "enabled": false
    },
    "payment_element": {
      "enabled": false,
      "features": {
        "payment_method_allow_redisplay_filters": [
          "unspecified"
        ],
        "payment_method_redisplay": "disabled",
        "payment_method_redisplay_limit": null,
        "payment_method_remove": "enabled",
        "payment_method_save": "disabled",
        "payment_method_save_usage": null
      }
    },
    "pricing_table": {
      "enabled": true
    },
    "customer_sheet": {
      "enabled": true,
      "features": {
        "payment_method_allow_redisplay_filters": null,
        "payment_method_remove": null
      }
    },
    "mobile_payment_element": {
      "enabled": true,
      "features": {
        "payment_method_allow_redisplay_filters": null,
        "payment_method_redisplay": null,
        "payment_method_remove": null,
        "payment_method_save": null,
        "payment_method_save_allow_redisplay_override": null
      }
    },
    "customer_portal": {
      "enabled": true
    },
    "active_entitlements": {
      "enabled": true
    }
  },
  "created": 1234567890,
  "customer": "cus_QXg1o8vcGmoR32",
  "expires_at": 1234567890,
  "livemode": false,
  "object": "customer_session",
  "customer_account": null
}

Operations and schemas come from the pinned Stripe OpenAPI specification (MIT); response examples from its fixtures. Nested object definitions and enums are in the complete specification.