contentstack User Sessions API

Endpoints for authenticating users and managing session tokens within Contentstack.

OpenAPI Specification

contentstack-user-sessions-api-openapi.yml Raw ↑
openapi: 3.1.0
info:
  title: Contentstack Analytics Accounts User Sessions API
  description: The Contentstack Analytics API provides access to usage and performance metrics for CMS, Launch, and Automate products within a Contentstack organization. Developers can retrieve analytics data programmatically to build custom dashboards, monitor content delivery performance, and track platform usage against plan limits. The API returns structured data suitable for aggregation with external analytics and business intelligence tools. Access is restricted to organization Owners and Admins. Requests use async job-based processing where initial POST calls queue the job and a subsequent GET call retrieves the results.
  version: v2
  contact:
    name: Contentstack Support
    url: https://www.contentstack.com/contact
  termsOfService: https://www.contentstack.com/legal/terms-of-service
servers:
- url: https://api.contentstack.io
  description: AWS North America Production Server
- url: https://eu-api.contentstack.com
  description: AWS Europe Production Server
- url: https://au-api.contentstack.com
  description: AWS Australia Production Server
security:
- bearerAuth: []
- authtokenAuth: []
tags:
- name: User Sessions
  description: Endpoints for authenticating users and managing session tokens within Contentstack.
paths:
  /user-session:
    post:
      operationId: loginUser
      summary: Log in a user
      description: Authenticates a user with their email and password and returns an authtoken for use in subsequent API requests. The authtoken is valid for the duration of the session.
      tags:
      - User Sessions
      security: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/LoginRequest'
      responses:
        '200':
          description: Successful authentication with authtoken.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/LoginResponse'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
    delete:
      operationId: logoutUser
      summary: Log out a user
      description: Invalidates the current user session and authtoken, signing the user out of all Contentstack sessions.
      tags:
      - User Sessions
      responses:
        '200':
          description: Successfully logged out.
        '401':
          $ref: '#/components/responses/Unauthorized'
components:
  schemas:
    LoginRequest:
      type: object
      description: Credentials for user authentication.
      required:
      - user
      properties:
        user:
          type: object
          description: User credential object.
          required:
          - email
          - password
          properties:
            email:
              type: string
              format: email
              description: The user's email address.
            password:
              type: string
              format: password
              description: The user's account password.
    LoginResponse:
      type: object
      description: Authentication response containing the user's authtoken.
      properties:
        user:
          $ref: '#/components/schemas/User'
    User:
      type: object
      description: A Contentstack user account.
      properties:
        uid:
          type: string
          description: Unique identifier of the user.
        first_name:
          type: string
          description: User's first name.
        last_name:
          type: string
          description: User's last name.
        email:
          type: string
          format: email
          description: User's email address.
        authtoken:
          type: string
          description: Session authentication token. Only returned on login.
        created_at:
          type: string
          format: date-time
          description: ISO 8601 timestamp when the user account was created.
    Error:
      type: object
      description: Standard error response.
      properties:
        error_message:
          type: string
          description: Human-readable description of the error.
        error_code:
          type: integer
          description: Numeric error code.
        errors:
          type: object
          description: Field-level validation errors.
  responses:
    Unauthorized:
      description: Authentication credentials are missing or invalid.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    BadRequest:
      description: The request is malformed or contains invalid parameters.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: OAuth 2.0 Bearer token (M2M) with analytics access.
    authtokenAuth:
      type: apiKey
      in: header
      name: authtoken
      description: Contentstack user authtoken. Only organization Owners and Admins can access analytics.
externalDocs:
  description: Contentstack Analytics API Documentation
  url: https://www.contentstack.com/docs/developers/apis/analytics-api