> ## 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.

# Process USSD Request

> Processes a customer's ussd request



## OpenAPI

````yaml api-reference/openapi-ussd.yaml post /process
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:
  /process:
    parameters:
      - $ref: '#/components/parameters/Signature'
      - $ref: '#/components/parameters/SignatureInput'
      - $ref: '#/components/parameters/XCliendId'
    post:
      tags:
        - Process
      summary: Processes a customer's ussd request
      parameters:
        - $ref: '#/components/parameters/CustomerIdParam'
      requestBody:
        description: Details used to process a customer's ussd request
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ProcessRequest'
      responses:
        '200':
          description: USSD request processed successfully
          content:
            application/json:
              schema:
                allOf:
                  - $ref: '#/components/schemas/Success'
                  - type: object
                    properties:
                      data:
                        $ref: '#/components/schemas/ProcessResponse'
              examples:
                stocksMenu:
                  summary: Stocks menu response
                  value:
                    message: USSD request processed successfully
                    data:
                      sessionId: ussd_3278668b308502f3a562950fc8043028
                      currentState: STOCKS
                      menu:
                        state: STOCKS
                        text: 'Select Stock:'
                        options:
                          - key: '1'
                            label: AAPL
                            nextState: SELECT_STOCK
                            data:
                              stockId: cmhkp4jkw0005zxfok9m0kiwg
                              symbol: AAPL
                              name: Apple Inc.
                          - key: '2'
                            label: AMZN
                            nextState: SELECT_STOCK
                            data:
                              stockId: cmhkp4kcp0008zxfohlxjtvd7
                              symbol: AMZN
                              name: Amazon.com Inc.
                          - key: '3'
                            label: GOOGL
                            nextState: SELECT_STOCK
                            data:
                              stockId: cmhkp4juc0006zxfo52azbrvo
                              symbol: GOOGL
                              name: Alphabet Inc.
                          - key: '4'
                            label: JPM
                            nextState: SELECT_STOCK
                            data:
                              stockId: cmhkp4ldl000czxfoqdqmzur8
                              symbol: JPM
                              name: JPMorgan Chase & Co.
                          - key: '5'
                            label: META
                            nextState: SELECT_STOCK
                            data:
                              stockId: cmhkp4kv7000azxfoi6s5yw7j
                              symbol: META
                              name: Meta Platforms Inc.
                          - key: '7'
                            label: Next Page
                          - key: '8'
                            label: Search Stock
                            nextState: SEARCH_STOCK
                          - key: '0'
                            label: Back to Home
                            nextState: HOME
                        isEndState: false
                      ussdText: |-
                        Select Stock:

                        1. AAPL
                        2. AMZN
                        3. GOOGL
                        4. JPM
                        5. META
                        7. Next Page
                        8. Search Stock
                        0. Back to Home
                      expiresAt: '2025-11-06T14:38:12.202Z'
        '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:
    ProcessRequest:
      type: object
      properties:
        sessionId:
          $ref: '#/components/schemas/SessionId'
        choice:
          $ref: '#/components/schemas/Choice'
      required:
        - sessionId
        - choice
    Success:
      type: object
      properties:
        data:
          oneOf:
            - type: object
            - type: array
        code:
          $ref: '#/components/schemas/ResponseCode'
        message:
          $ref: '#/components/schemas/ResponseMessage'
      required:
        - data
        - code
        - message
    ProcessResponse:
      type: object
      description: The USSD process request response data
      properties:
        sessionId:
          $ref: '#/components/schemas/SessionId'
        currentState:
          type: string
          description: The current state of the session after processing
          example: STOCKS
        menu:
          $ref: '#/components/schemas/Menu'
        ussdText:
          type: string
          description: The formatted USSD text to display to the user
          example: |-
            Select Stock:

            1. AAPL
            2. AMZN
            3. GOOGL
            4. JPM
            5. META
            7. Next Page
            8. Search Stock
            0. Back to Home
        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
    SessionId:
      description: Unique session identifier
      type: string
      example: ussd_3278668b308502f3a562950fc8043028
    Choice:
      description: >-
        The choice made by the customer (can be an integer like 1, 2, 3, 4 or a
        string like "Tesla", "Apple", "Gold")
      oneOf:
        - type: integer
          example: 1
        - type: string
          example: Tesla
    ResponseCode:
      description: Request response code
      type: string
      example: 200
    ResponseMessage:
      description: Request response message
      type: string
      example: Success
    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

````