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

# Create Session

> Creates a customer session



## OpenAPI

````yaml api-reference/openapi-ussd.yaml post /session
openapi: 3.0.0
info:
  title: Pipevest Investment API
  description: Connecting millions of Africans to the global economy
  version: 0.0.1
servers:
  - url: https://api.pipevest.com/v1/ussd
    description: Production server
  - url: https://api.staging.pipevest.com/v1/ussd
    description: Staging server
security:
  - BearerAuth: []
paths:
  /session:
    parameters:
      - $ref: '#/components/parameters/Signature'
      - $ref: '#/components/parameters/SignatureInput'
      - $ref: '#/components/parameters/XCliendId'
    post:
      tags:
        - Session
      summary: Creates a customer session
      parameters:
        - $ref: '#/components/parameters/CustomerIdParam'
      requestBody:
        description: Details used to create a customer session
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateSession'
      responses:
        '200':
          description: Customer session created successfully
          content:
            application/json:
              schema:
                allOf:
                  - $ref: '#/components/schemas/Success'
                  - type: object
                    properties:
                      data:
                        $ref: '#/components/schemas/Session'
        '401':
          $ref: '#/components/responses/Unauthorized'
components:
  parameters:
    Signature:
      in: header
      name: Signature
      schema:
        type: string
        example: 'sig1=:OTEyMjY4...A5NTNDMEQ=:'
        description: >
          Base64 encoded signed hash of the http message request components.


          [Learn how signatures
          work](/concepts/http-signature/message-signature)
      required: true
    SignatureInput:
      in: header
      name: Signature-Input
      schema:
        type: string
        example: sig1=("Content-Type" "Content-Digest"...expires=<expires>
        description: >
          An ordered list of components that make up the signature base. It is
          used to recompute and verify the `Signature`


          [Learn how signatures
          work](/concepts/http-signature/message-signature)
      required: true
    XCliendId:
      in: header
      name: X-Client-Id
      schema:
        $ref: '#/components/schemas/ClientId'
      example: client-id
      required: true
    CustomerIdParam:
      in: query
      name: customerId
      required: true
      example: 123456
      schema:
        $ref: '#/components/schemas/CustomerId'
  schemas:
    CreateSession:
      type: object
      properties:
        customerId:
          $ref: '#/components/schemas/CustomerId'
      required:
        - customerId
    Success:
      type: object
      properties:
        data:
          oneOf:
            - type: object
            - type: array
        code:
          $ref: '#/components/schemas/ResponseCode'
        message:
          $ref: '#/components/schemas/ResponseMessage'
      required:
        - data
        - code
        - message
    Session:
      type: object
      description: The USSD session response data
      properties:
        sessionId:
          $ref: '#/components/schemas/SessionId'
        currentState:
          type: string
          description: The current state of the session
          example: HOME
        menu:
          $ref: '#/components/schemas/Menu'
        ussdText:
          type: string
          description: The formatted USSD text to display to the user
          example: |-
            Select an investment option:

            1. Stocks
            2. My Portfolio
        expiresAt:
          type: string
          format: date-time
          description: The expiration timestamp of the session
          example: '2025-11-06T14:38:12.202Z'
      required:
        - sessionId
        - currentState
        - menu
        - ussdText
        - expiresAt
    ClientId:
      description: Unique identifier assigned to the client
      type: string
      example: client-id
    CustomerId:
      description: Unique customer identifier
      type: integer
      example: 123456
    ResponseCode:
      description: Request response code
      type: string
      example: 200
    ResponseMessage:
      description: Request response message
      type: string
      example: Success
    SessionId:
      description: Unique session identifier
      type: string
      example: ussd_3278668b308502f3a562950fc8043028
    Menu:
      type: object
      description: The menu structure with state, text, options, and end state flag
      properties:
        state:
          type: string
          description: The current menu state
          example: HOME
        text:
          type: string
          description: The menu text to display
          example: 'Select an investment option:'
        options:
          type: array
          description: Array of menu options
          items:
            $ref: '#/components/schemas/MenuOption'
          example:
            - key: '1'
              label: Stocks
              nextState: STOCKS
            - key: '2'
              label: My Portfolio
              nextState: MY_PORTFOLIO
        isEndState:
          type: boolean
          description: Whether this is an end state (session terminates)
          example: false
      required:
        - state
        - text
        - options
        - isEndState
    Error:
      type: object
      properties:
        code:
          allOf:
            - $ref: '#/components/schemas/ResponseCode'
            - example: 401
        message:
          allOf:
            - $ref: '#/components/schemas/ResponseMessage'
            - example: Unauthorized
      required:
        - code
        - message
    MenuOption:
      type: object
      description: A menu option with key, label, optional next state, and optional data
      properties:
        key:
          type: string
          description: The option key (e.g., "1", "2", or "Tesla", "Apple")
          example: '1'
        label:
          type: string
          description: The display label for the option
          example: Stocks
        nextState:
          type: string
          description: >-
            The next state to transition to (optional, some options like "Next
            Page" may not have this)
          example: STOCKS
        data:
          type: object
          description: >-
            Optional additional data associated with the option (e.g., stock
            information)
          properties:
            stockId:
              type: string
              description: Unique stock identifier
              example: cmhkp4jkw0005zxfok9m0kiwg
            symbol:
              type: string
              description: Stock symbol
              example: AAPL
            name:
              type: string
              description: Stock name
              example: Apple Inc.
          example:
            stockId: cmhkp4jkw0005zxfok9m0kiwg
            symbol: AAPL
            name: Apple Inc.
      required:
        - key
        - label
  responses:
    Unauthorized:
      description: Unauthorized
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer

````