POST
/
project
/
{project_id}
/
chart
/
{id}
/
share
/
token
curl -X POST \
  'https://api.chartbrew.com/project/123/chart/456/share/token' \
  -H 'Authorization: Bearer YOUR_API_TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{
    "share_policy": {
      "params": [
        {
          "key": "filter_date",
          "value": "2024-01"
        },
        {
          "key": "category",
          "value": "sales"
        }
      ],
      "allow_params": true
    },
    "exp": "2024-12-31T23:59:59Z"
  }'
{
  "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOnsidHlwZSI6IkNoYXJ0IiwiaWQiOjQ1Nn0sImlhdCI6MTY0MjQ0MDAwMCwiZXhwIjoxNzAzOTc2MDAwfQ.example_signature",
  "url": "https://app.chartbrew.com/chart/abc123/embedded?token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOnsidHlwZSI6IkNoYXJ0IiwiaWQiOjQ1Nn0sImlhdCI6MTY0MjQ0MDAwMCwiZXhwIjoxNzAzOTc2MDAwfQ.example_signature"
}
This endpoint generates a JWT token for embedding a chart with a SharePolicy. The token can include custom parameters, expiration dates, and URL parameter permissions.

Parameters

project_id
string
required
The ID of the project containing the chart
id
string
required
The ID of the chart

Body Parameters

share_policy
object
Share policy configuration to update before generating token
exp
string
Token expiration date and time in ISO 8601 format (e.g., “2024-12-31T23:59:59Z”)

Response

token
string
The generated JWT access token for chart access
url
string
The complete embeddable URL with the access token included

Example

curl -X POST \
  'https://api.chartbrew.com/project/123/chart/456/share/token' \
  -H 'Authorization: Bearer YOUR_API_TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{
    "share_policy": {
      "params": [
        {
          "key": "filter_date",
          "value": "2024-01"
        },
        {
          "key": "category",
          "value": "sales"
        }
      ],
      "allow_params": true
    },
    "exp": "2024-12-31T23:59:59Z"
  }'
{
  "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOnsidHlwZSI6IkNoYXJ0IiwiaWQiOjQ1Nn0sImlhdCI6MTY0MjQ0MDAwMCwiZXhwIjoxNzAzOTc2MDAwfQ.example_signature",
  "url": "https://app.chartbrew.com/chart/abc123/embedded?token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOnsidHlwZSI6IkNoYXJ0IiwiaWQiOjQ1Nn0sImlhdCI6MTY0MjQ0MDAwMCwiZXhwIjoxNzAzOTc2MDAwfQ.example_signature"
}

Usage Notes

  • Prerequisites: A SharePolicy must exist for the chart before generating tokens. Use the “Create Chart Share Policy” endpoint first.
  • Token Expiration: If no expiration is specified, the token will have a very long expiration (99999 days).
  • Parameters: Parameters defined in the share policy will be passed as variables to the chart.
  • URL Parameters: If allow_params is true, additional parameters can be passed via URL query parameters and will override policy parameters.
  • Embedding: Use the returned URL in an iframe or directly link to it for chart embedding.
  • Security: Always use HTTPS when sharing URLs containing access tokens.

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Path Parameters

project_id
string
required

ID of the project

id
string
required

ID of the chart

Body

application/json

Response

200
application/json

Generated chart share token and URL

The response is of type object.