> ## Documentation Index
> Fetch the complete documentation index at: https://docs.bily.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Get customer context

> Returns the authenticated user with accessible organizations and their nested stores in one request. A store-scoped API key is narrowed automatically; use organizationId only to explicitly select an accessible organization.



## OpenAPI

````yaml /openapi.json get /context
openapi: 3.1.0
info:
  title: Bily API
  version: 1.0.0
  description: >-
    Discover stores, read analytics and commerce data, inspect connections, and
    run explicitly authorized actions with the Bily API.
  contact:
    name: Bily support
    email: support@bily.ai
servers:
  - url: https://app.bily.ai/api/customer/v1
    description: Production
security:
  - ApiKeyAuth: []
  - BearerAuth: []
tags:
  - name: Identity
    description: Discover the identity and organizations attached to a key.
  - name: Stores
    description: Discover stores within an organization.
  - name: Store data
    description: Read store profiles, readiness, catalogs, and connected accounts.
  - name: Commerce
    description: Run scoped commerce reads and explicitly approved GraphQL mutations.
  - name: Analytics
    description: >-
      Read normalized advertising, attribution, product, customer, and cohort
      metrics.
  - name: Analytics SQL
    description: Run constrained read-only SQL over store-scoped Bily datasets.
  - name: Customer journeys
    description: Read customer touchpoints within an authenticated store scope.
  - name: Connections
    description: Inspect available connections, support, and advertising assets.
  - name: Supported actions
    description: Synchronize connections and update supported advertising assets.
  - name: Campaign actions
    description: Create or clone supported advertising campaign resources.
  - name: Tracking connections
    description: >-
      List and manage store-scoped tracking connections without returning
      credential secrets.
paths:
  /context:
    get:
      tags:
        - Identity
      summary: Get customer context
      description: >-
        Returns the authenticated user with accessible organizations and their
        nested stores in one request. A store-scoped API key is narrowed
        automatically; use organizationId only to explicitly select an
        accessible organization.
      operationId: getContext
      parameters:
        - name: organizationId
          in: query
          description: >-
            An explicitly selected accessible organization. Omit this parameter
            for an ordinary store-scoped API key; Bily uses the organization and
            store recorded on the key.
          required: false
          schema:
            type: string
      responses:
        '200':
          description: Request completed successfully.
          headers:
            x-request-id:
              description: The request identifier selected or generated by Bily.
              schema:
                type: string
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ContextResponse'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '500':
          $ref: '#/components/responses/ServerError'
components:
  schemas:
    ContextResponse:
      type: object
      required:
        - user
        - organizations
      properties:
        user:
          $ref: '#/components/schemas/User'
        organizations:
          type: array
          items:
            $ref: '#/components/schemas/ContextOrganization'
    User:
      type: object
      required:
        - id
        - email
        - emailVerified
        - name
        - image
      properties:
        id:
          type: string
        email:
          type: string
          format: email
        emailVerified:
          type: boolean
        name:
          type: string
        image:
          type:
            - string
            - 'null'
    ContextOrganization:
      type: object
      required:
        - id
        - name
        - slug
        - createdAt
        - stores
      properties:
        id:
          type: string
        name:
          type: string
        slug:
          type: string
        role:
          type: string
          description: >-
            The authenticated user's organization role when membership supplies
            one.
        createdAt:
          type:
            - string
            - integer
          description: Organization creation time.
        stores:
          type: array
          items:
            $ref: '#/components/schemas/Store'
    Error:
      type: object
      required:
        - error
      properties:
        error:
          type: string
          example: Store not found
        requestId:
          type: string
          description: Present on some server errors.
        details:
          description: Optional safe details for an action failure.
        retryAfter:
          type:
            - string
            - 'null'
      additionalProperties: true
    Store:
      type: object
      required:
        - id
        - url
        - type
        - currency
        - createdAt
        - updatedAt
      properties:
        id:
          type: string
        url:
          type: string
          example: store.example.com
        type:
          type: string
        currency:
          type:
            - string
            - 'null'
        createdAt:
          type:
            - string
            - integer
        updatedAt:
          type:
            - string
            - integer
  responses:
    BadRequest:
      description: The request path, query, or body is invalid.
      headers:
        x-request-id:
          description: The request identifier selected or generated by Bily.
          schema:
            type: string
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    Unauthorized:
      description: Authentication is missing or invalid.
      headers:
        x-request-id:
          description: The request identifier selected or generated by Bily.
          schema:
            type: string
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    Forbidden:
      description: The identity or API key is not allowed to perform this request.
      headers:
        x-request-id:
          description: The request identifier selected or generated by Bily.
          schema:
            type: string
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    ServerError:
      description: Bily could not complete the request.
      headers:
        x-request-id:
          description: The request identifier selected or generated by Bily.
          schema:
            type: string
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: x-api-key
      description: >-
        A server-side Bily API key created under Settings > MCP > Access key
        fallback. Select the intended store before creating it.
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: Bily API key
      description: An alternative way to send the same server-side Bily API key.

````