Subchapter 22.9
references/quick-start.mdMarkdown4 KBView on GitHub
Basic project creation patterns for getting started quickly.
projects:write permissionLAUNCHDARKLY_API_TOKEN environment variableEndpoint: POST https://app.launchdarkly.com/api/v2/projects
Required Headers:
Authorization: {YOUR_API_TOKEN}
Content-Type: application/jsonMinimal Payload:
{
"name": "My Agent Project",
"key": "my-ai-project"
}Recommended Payload:
{
"name": "Customer Support Agent",
"key": "support-ai",
"tags": ["ai-configs", "production"]
}{
"name": "Customer Support Agent",
"key": "support-ai",
"environments": {
"items": [
{
"name": "Production",
"key": "production",
"apiKey": "sdk-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
},
{
"name": "Test",
"key": "test",
"apiKey": "sdk-yyyyyyyy-yyyy-yyyy-yyyy-yyyyyyyyyyyy"
}
]
}
}Action: Extract and save SDK keys for use in your application.
Project with that key already exists.
Action: Either use the existing project or choose a different key.
{
"code": "invalid_request",
"message": "project key must be lowercase with hyphens"
}Action: Fix the payload based on error message.
Must follow these constraints:
^[a-z][a-z0-9-]*$support-ai
chat-bot-v2
recommendation-engine
customer-ai-prodSupport_AI # uppercase and underscore
123-project # starts with number
my.project # contains dot
ai_chatbot # underscore not allowedAfter creating a project, you’ll need the SDK keys to connect your application.
production)test)Endpoint: GET https://app.launchdarkly.com/api/v2/projects/{projectKey}?expand=environments
Parse Response:
{
"environments": {
"items": [
{
"key": "production",
"apiKey": "sdk-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
}
]
}
}Filter by environment.key to find the desired environment’s apiKey.
Before creating a new project, you may want to check what exists.
Endpoint: GET https://app.launchdarkly.com/api/v2/projects
Response:
{
"items": [
{
"name": "Customer Support Agent",
"key": "support-ai",
"tags": ["ai-configs"]
}
]
}| Mistake | Problem | Fix |
|---|---|---|
| Uppercase in key | Rejected by API | Use lowercase only |
| Spaces in key | Invalid format | Use hyphens instead |
| Key collision | 409 conflict | Choose unique key or use existing |
| Missing API token | 401 unauthorized | Set LAUNCHDARKLY_API_TOKEN |
| Wrong permission | 403 forbidden | Request projects:write permission |
After creating your project:
See Environment Configuration for saving SDK keys to your codebase.