Skip to main content
All URIs are relative to https://api.elections.kalshi.com/trade-api/v2
MethodHTTP requestDescription
create_api_keyPOST /api_keysCreate API Key
delete_api_keyDELETE /api_keys/Delete API Key
generate_api_keyPOST /api_keys/generateGenerate API Key
get_api_keysGET /api_keysGet API Keys

create_api_key

CreateApiKeyResponse create_api_key(create_api_key_request)
Create API Key Endpoint for creating a new API key with a user-provided public key. This endpoint allows users with Premier or Market Maker API usage levels to create API keys by providing their own RSA public key. The platform will use this public key to verify signatures on API requests.

Parameters

NameTypeDescriptionNotes
create_api_key_requestCreateApiKeyRequest

Return type

CreateApiKeyResponse

HTTP response details

Status codeDescription
201API key created successfully
400Bad request - invalid input
401Unauthorized
403Forbidden - insufficient API usage level
500Internal server error

delete_api_key

delete_api_key(api_key)
Delete API Key Endpoint for deleting an existing API key. This endpoint permanently deletes an API key. Once deleted, the key can no longer be used for authentication. This action cannot be undone.

Parameters

NameTypeDescriptionNotes
api_keystrAPI key ID to delete

Return type

void (empty response body)

HTTP response details

Status codeDescription
204API key successfully deleted
400Bad request - invalid API key ID
401Unauthorized
404API key not found
500Internal server error

generate_api_key

GenerateApiKeyResponse generate_api_key(generate_api_key_request)
Generate API Key Endpoint for generating a new API key with an automatically created key pair. This endpoint generates both a public and private RSA key pair. The public key is stored on the platform, while the private key is returned to the user and must be stored securely. The private key cannot be retrieved again.

Parameters

NameTypeDescriptionNotes
generate_api_key_requestGenerateApiKeyRequest

Return type

GenerateApiKeyResponse

HTTP response details

Status codeDescription
201API key generated successfully
400Bad request - invalid input
401Unauthorized
500Internal server error

get_api_keys

GetApiKeysResponse get_api_keys()
Get API Keys Endpoint for retrieving all API keys associated with the authenticated user. API keys allow programmatic access to the platform without requiring username/password authentication. Each key has a unique identifier and name.

Parameters

This endpoint does not need any parameter.

Return type

GetApiKeysResponse

HTTP response details

Status codeDescription
200List of API keys retrieved successfully
401Unauthorized
500Internal server error