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

# Track Metadata

Associate metadata with an existing request log. Use this for values such as session IDs, user IDs, environment names, regions, or other searchable request context.

## Related

* [Track Prompt](/reference/track-prompt)
* [Metadata](/features/prompt-history/metadata)
* [Log Request](/reference/log-request)


## OpenAPI

````yaml POST /rest/track-metadata
openapi: 3.1.0
info:
  title: FastAPI
  version: 0.1.0
servers: []
security:
  - ApiKeyAuth: []
paths:
  /rest/track-metadata:
    post:
      tags:
        - metadata
      summary: Track Metadata
      operationId: trackMetadata
      requestBody:
        required: true
        description: Metadata tracking payload.
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/TrackMetadataRequest'
            examples:
              metadata:
                summary: Track metadata
                value:
                  request_id: 12345
                  metadata:
                    session_id: abc123
                    user_id: user123
      responses:
        '200':
          description: Metadata saved.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TrackResponse'
              examples:
                tracked:
                  summary: Tracked
                  value:
                    success: true
                    message: Metadata tracked successfully
        '400':
          description: Bad Request
        '401':
          $ref: '#/components/responses/UnauthorizedError'
        '422':
          $ref: '#/components/responses/ValidationError'
components:
  schemas:
    TrackMetadataRequest:
      type: object
      title: TrackMetadataRequest
      required:
        - request_id
        - metadata
      properties:
        request_id:
          anyOf:
            - type: integer
            - type: string
          description: PromptLayer request ID to update.
        metadata:
          type: object
          additionalProperties: true
          description: Metadata dictionary to associate with the request.
    TrackResponse:
      type: object
      title: TrackResponse
      required:
        - success
        - message
      properties:
        success:
          type: boolean
        message:
          type: string
    ErrorResponse:
      type: object
      properties:
        success:
          type: boolean
          default: false
          description: Indicates that the request failed.
        message:
          type: string
          description: Human-readable error message.
        error:
          type: string
          description: Machine-readable or fallback error message.
      additionalProperties: true
      description: >-
        Standard error response. Some legacy endpoints may return either message
        or error.
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
  responses:
    UnauthorizedError:
      description: Unauthorized - missing or invalid API key.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    ValidationError:
      description: Validation error - request parameters or body are invalid.
      content:
        application/json:
          schema:
            oneOf:
              - $ref: '#/components/schemas/HTTPValidationError'
              - $ref: '#/components/schemas/ErrorResponse'
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: X-API-KEY

````