API
Core Resources

Customer sessionsNew

Customer sessions are short-lived tokens scoped to a single Customer. They allow a storefront or application to act on behalf of that customer without exposing the store's API token.

This resource is new in the V2 reference. It also works when you send X-Recharge-Version: 2021-11.

#The customer session object

Attributes

  • apiTokenstring
    The session token scoped to the Customer.
  • customerIdinteger
    Unique numeric identifier for the Customer the session was created for.
  • The email address of the store user the session was created for.
    Only returned when creating a customer support session.
The customer session object
{
  "customer_session": {
    "apiToken": "eyJhbGciOiJIUzI1NiJ9.example.signature",
    "customerId": 90210001
  }
}

#Create a customer session

POST/customers/{id}/sessions
Creates a session token for a Customer. Send an empty JSON object as the request body. If a storefront access token is passed in the X-Recharge-Storefront-Access-Token header, the scopes of the session are derived from that token.
Scopewrite_sessions
POST/customers/{id}/sessions
curl -X POST 'https://api.rechargeapps.com/customers/129593/sessions' \
  -H 'X-Recharge-Version: v2' \
  -H 'X-Recharge-Access-Token: your_api_token'
Response
{
  "customer_session": {
    "apiToken": "eyJhbGciOiJIUzI1NiJ9.example.signature",
    "customerId": 90210001
  }
}