Overview
Published API endpoints allow you to publish bots as standalone APIs with their own endpoints, API keys, rate limits, and CORS configuration. This is ideal for integrating bots into external applications.Bot Publication Flow
- Publish a Bot: Create an API Gateway deployment for a shared bot
- Create API Keys: Generate API keys for authentication
- Use Published API: Call the bot through its dedicated endpoint
- Manage & Monitor: Update settings or delete the publication
Publish Bot
Path Parameters
The bot ID to publish (must be a shared bot you own)
Request Body
API Gateway stage name (e.g.,
"dev", "stg", "prd"). Defaults to "api" if not specified.Request quota configuration
Request throttling configuration
Array of allowed CORS origins. Each must start with
"http://" or "https://", or be "*" for all origins.Requirements
- Bot must be shared (not private)
- Bot must not already be published
- No CloudFormation deployment can be in progress
Example Request
Get Bot Publication
Path Parameters
The published bot ID
Response
The API Gateway stage (e.g.,
"dev", "stg", "prd")Quota configuration
Throttling configuration
Array of allowed CORS origins
CloudFormation deployment status
CodeBuild project ID for the deployment
CodeBuild status:
"IN_PROGRESS", "SUCCEEDED", "FAILED", etc.API Gateway endpoint URL (null until deployment succeeds)
Array of API key IDs created for this publication
Example Response
Notes
- Returns 404 if the bot is not published
- If CodeBuild has not succeeded, only
codebuild_id,codebuild_status, andcfn_statuswill have values - Can be used by both owner and admin
Delete Bot Publication
Path Parameters
The published bot ID to unpublish
Requirements
- Bot must be published
- CodeBuild must be completed (status must be
"SUCCEEDED"or"FAILED") - Cannot delete while deployment is in progress
Create API Key
Path Parameters
The published bot ID
Request Body
Description of the API key (e.g., purpose or application name)
Response
Unique API key identifier
API key description
The API key value (only returned on creation)
Whether the API key is enabled
Unix timestamp of creation
Example Request
Example Response
Get API Key
Path Parameters
The published bot ID
The API key ID to retrieve
Response
Returns API key details (same structure as create response, butvalue is masked).
Delete API Key
Path Parameters
The published bot ID
The API key ID to delete
Using Published Bot APIs
Once a bot is published, it gets its own API endpoint. Here’s how to use it:Base URL
The base URL is returned in the publication endpoint:Authentication
Include the API key in the request header:Send Message
Request Body
Conversation ID (auto-generated if not provided)
Message object
Continue generation from last message
Enable reasoning mode
Response
The conversation identifier
The message ID for the response
Example Request
Example Response
Async Processing: The message is queued for processing via SQS. Use the returned
message_id to retrieve the response.Get Conversation
Path Parameters
The conversation ID
Response
Returns the full conversation object with all messages (same structure as the main conversation API).Get Specific Message
Path Parameters
The conversation ID
The message ID from the send message response
Response
The conversation identifier
The bot’s response message
Unix timestamp of conversation creation
Rate Limiting
Published APIs enforce the configured rate limits:Quota Limits
- Tracks total requests over a time period (DAY/WEEK/MONTH)
- Returns HTTP 429 when quota is exceeded
- Resets at the beginning of each period
Throttling
rate_limit: Maximum requests per secondburst_limit: Maximum concurrent requests- Returns HTTP 429 when throttle is exceeded
Rate Limit Headers
Responses include rate limit information:CORS Configuration
Theallowed_origins setting controls which domains can access the API from browsers:
- Specific origins:
["https://app.example.com", "https://dashboard.example.com"] - All origins:
["*"](use with caution in production)
Best Practices
-
API Key Security
- Store API keys securely (environment variables, secrets manager)
- Never commit keys to version control
- Rotate keys periodically
- Use separate keys for different environments
-
Rate Limiting
- Set appropriate limits based on expected usage
- Monitor usage to adjust limits as needed
- Implement exponential backoff in client applications
-
CORS Configuration
- Specify exact origins in production (avoid
*) - Update origins when deploying to new domains
- Specify exact origins in production (avoid
-
Monitoring
- Track API key usage
- Monitor rate limit violations
- Check CodeBuild deployment status
-
Deployment
- Wait for
codebuild_statusto beSUCCEEDEDbefore using - Use different stages for development and production
- Test with development keys before deploying
- Wait for