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

# Venue keys

> Store the user's Kalshi API key, which every Kalshi trade uses, then read whether it is connected.

This is the user's venue credential. Every Kalshi trade, managed or [self-custody](/recipes/self-custody), uses it. See [Kalshi](/venues/kalshi). It is not your app's `x-app-api-key`. Authenticate with `x-app-id` and `Authorization: Bearer`. The stored secret is never returned.

<CodeGroup>
  ```ts SDK theme={null}
  import { Venue } from "@agg-build/sdk";

  await client.upsertVenueKey({
    venue: Venue.kalshi,
    credentials: { keyId, privateKey },
  });
  const status = await client.getVenueKeyStatus(Venue.kalshi);
  // status.connected, status.validatedAt, status.kycStatus
  ```

  ```bash cURL theme={null}
  curl -s -X PUT \
    -H "x-app-id: $APP_ID" -H "Authorization: Bearer $ACCESS_TOKEN" \
    -H "Content-Type: application/json" \
    -d "$(jq -n --arg keyId "$KEY_ID" --arg privateKey "$KALSHI_PEM" \
      '{venue: "kalshi", credentials: {keyId: $keyId, privateKey: $privateKey}}')" \
    "$API/venue-keys"

  curl -s -H "x-app-id: $APP_ID" -H "Authorization: Bearer $ACCESS_TOKEN" \
    "$API/venue-keys/kalshi/status"
  ```
</CodeGroup>

The cURL example uses `jq` to JSON-encode the PEM key, preserving its line breaks. Keep the key
out of source control and logs.

Full shapes on [Upsert a venue API key](/api-reference/users/upsert-a-venue-api-key) and [Get venue key connection status](/api-reference/users/get-venue-key-connection-status).

List stored summaries with [List venue keys](/api-reference/users/list-venue-keys) (`client.listVenueKeys()`). Remove one with [Delete a venue key](/api-reference/users/delete-a-venue-key) (`client.deleteVenueKey(Venue.kalshi)`).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.