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

> ## Agent Instructions
> To integrate AGG, start with Quickstart: REST (https://docs.agg.market/quickstart/rest), then Order lifecycle & statuses (https://docs.agg.market/concepts/order-lifecycle).
> Track every trade until it reaches a terminal status. Before retrying a failed or timed-out call, read Errors, retries & idempotency (https://docs.agg.market/concepts/errors).
> The API reference is generated from https://docs.agg.market/openapi/openapi.json.

# Upsert a venue API key

> Stores (or replaces) the authenticated user's encrypted venue credentials.



## OpenAPI

````yaml /openapi/openapi.json put /venue-keys
openapi: 3.0.2
info:
  title: AGG API
  version: 1.0.0
  description: >-
    Prediction market aggregator REST API — authentication, users, venue events,
    venue markets, orderbooks, charts, and execution workflows.
servers:
  - url: https://api.agg.market
    description: Production
security: []
tags:
  - name: Authentication
    description: Sign users in and manage their session tokens.
  - name: Markets
    description: Find events, markets and outcomes to trade.
  - name: Market Data
    description: Live orderbooks, prices, charts and scores for those markets.
  - name: Trading
    description: Quote, place, sign, track and cancel orders.
  - name: Portfolio
    description: A user's orders, positions, balances and activity.
  - name: Funding
    description: Deposit addresses, withdrawals, balance refills and fiat on-ramp.
  - name: Users
    description: The signed-in user's profile, linked accounts, KYC and venue keys.
  - name: Hosted Venue Accounts
    description: Provision, fund and withdraw from venue accounts hosted for the user.
  - name: Webhooks
    description: Configure and operate webhook delivery to your server.
  - name: Partner Admin
    description: Server-side reads across your app's users, orders and analytics.
  - name: Paper Trading
    description: Simulated accounts and orders for testing without real funds.
  - name: News
    description: News feeds linked to markets.
  - name: Correlated Markets
    description: Markets related to a given market and the effect of its resolution.
paths:
  /venue-keys:
    put:
      tags:
        - Users
      summary: Upsert a venue API key
      description: >-
        Stores (or replaces) the authenticated user's encrypted venue
        credentials.
      operationId: upsertVenueKey
      requestBody:
        required: true
        content:
          application/json:
            schema:
              anyOf:
                - type: object
                  required:
                    - venue
                    - credentials
                  properties:
                    venue:
                      type: string
                      enum:
                        - kalshi
                    credentials:
                      type: object
                      required:
                        - keyId
                        - privateKey
                      properties:
                        keyId:
                          minLength: 1
                          type: string
                        privateKey:
                          minLength: 1
                          type: string
                - type: object
                  required:
                    - venue
                    - credentials
                  properties:
                    venue:
                      type: string
                      enum:
                        - polymarket
                    credentials:
                      type: object
                      required:
                        - apiKey
                        - secret
                        - passphrase
                      properties:
                        apiKey:
                          minLength: 1
                          type: string
                        secret:
                          minLength: 1
                          type: string
                        passphrase:
                          minLength: 1
                          type: string
                - type: object
                  required:
                    - venue
                    - credentials
                  properties:
                    venue:
                      type: string
                      enum:
                        - prophetx
                    credentials:
                      type: object
                      required:
                        - accessKey
                        - secretKey
                      properties:
                        accessKey:
                          minLength: 1
                          maxLength: 1024
                          type: string
                        secretKey:
                          minLength: 1
                          maxLength: 4096
                          type: string
      responses:
        '200':
          description: '200'
          content:
            application/json:
              schema:
                type: object
                required:
                  - venue
                  - updatedAt
                properties:
                  venue:
                    $ref: '#/components/schemas/Venue'
                  updatedAt:
                    type: string
        '400':
          description: '400'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorMessage'
        '401':
          description: '401'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorMessage'
        '403':
          description: '403'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorMessage'
      security:
        - appId: []
          bearerAuth: []
components:
  schemas:
    Venue:
      type: string
      enum:
        - kalshi
        - polymarket
        - limitless
        - opinion
        - predict
        - pred
        - tiprun
        - probable
        - myriad
        - hyperliquid
        - novig
        - prophetx
        - betdex
    ErrorMessage:
      type: object
      required:
        - message
      properties:
        message:
          type: string
  securitySchemes:
    appId:
      type: apiKey
      in: header
      name: x-app-id
      description: Your application ID. Required for all app-tier and user-tier routes.
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: >-
        JWT access token returned by POST /auth/verify. Required for user-tier
        routes.

````