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

# Record the postcode the user selected

> Fire-and-forget analytics for the host integration. Served by the platform host, not the gateway.



## OpenAPI

````yaml /api-reference/openapi.yaml post /v1/widget/selected
openapi: 3.1.0
info:
  title: NIPOST Postcode Gateway — Public API
  version: 0.1.0
  description: >
    Public API for Nigeria's national postcode system. Search and Lookup L1 are
    free; Lookup L2–L4 are commercial (credits); L5 is restricted. Authenticate
    with an API key.
servers:
  - url: https://api.postcode.gov.ng
    description: Production
  - url: http://localhost:8081
    description: Local gateway
security:
  - ApiKeyAuth: []
paths:
  /v1/widget/selected:
    post:
      summary: Record the postcode the user selected
      description: >-
        Fire-and-forget analytics for the host integration. Served by the
        platform host, not the gateway.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - selection
              properties:
                selection:
                  $ref: '#/components/schemas/PostcodeSelection'
      responses:
        '200':
          description: Recorded
        '400':
          description: Missing selection.postcode
        '401':
          description: Missing or invalid widget token
      security:
        - WidgetToken: []
      servers:
        - url: https://platform.postcode.gov.ng
          description: Production platform
        - url: http://localhost:8082
          description: Local platform
components:
  schemas:
    PostcodeSelection:
      type: object
      description: >-
        The single cross-platform payload every widget SDK delivers to its host
        app on selection (version 1). segments/names fields below the
        selection's level are null; latitude/longitude appear only when the
        key's lookup level permits point geometry.
      required:
        - version
        - postcode
        - formatted
        - level
        - source
      properties:
        version:
          type: integer
          example: 1
        postcode:
          type: string
          example: FC02A09DB09
          description: Compact canonical code
        formatted:
          type: string
          example: FC-02-A09-DB-09
        level:
          type: integer
          minimum: 1
          maximum: 5
        segments:
          type: object
          properties:
            state:
              type:
                - string
                - 'null'
              example: FC
            lga:
              type:
                - string
                - 'null'
              example: '02'
            district:
              type:
                - string
                - 'null'
              example: A09
            area:
              type:
                - string
                - 'null'
              example: DB
            unit:
              type:
                - string
                - 'null'
              example: '09'
        names:
          type: object
          properties:
            state:
              type:
                - string
                - 'null'
            lga:
              type:
                - string
                - 'null'
            district:
              type:
                - string
                - 'null'
            area:
              type:
                - string
                - 'null'
        latitude:
          type:
            - number
            - 'null'
        longitude:
          type:
            - number
            - 'null'
        source:
          type: string
          enum:
            - bookmark
            - search
        label:
          type:
            - string
            - 'null'
          description: Bookmark label when source=bookmark
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: X-API-Key
    WidgetToken:
      type: http
      scheme: bearer
      description: Short-lived widget session JWT from POST /v1/widget/session

````