Skip to content

feat: add import project API endpoint#643

Open
ajworkos wants to merge 2 commits intolaunchdarkly:mainfrom
ajworkos:feat/add-import-project-api
Open

feat: add import project API endpoint#643
ajworkos wants to merge 2 commits intolaunchdarkly:mainfrom
ajworkos:feat/add-import-project-api

Conversation

@ajworkos
Copy link
Contributor

@ajworkos ajworkos commented Feb 12, 2026

Summary

Add POST /projects/{projectKey}/import endpoint to the dev server API that allows importing a project from JSON data. This provides HTTP API parity with the existing CLI import-project command.

Changes

  • Add /projects/{projectKey}/import endpoint to OpenAPI spec (api.yaml)
  • Regenerate server.gen.go with new endpoint types and handlers
  • Implement PostImportProject handler in post_import_project.go
    • Reuses existing model.ImportProject() function for business logic
    • Validates required fields (sourceEnvironmentKey, flagsState)
    • Returns 409 Conflict if project already exists
    • Returns 400 Bad Request for missing/invalid fields
    • Returns 201 Created with project data on success

Motivation

The import-project functionality was recently added as a CLI command (commit 4d945b6), but was not exposed through the HTTP API. This creates an API gap

Implementation Details

The endpoint accepts the same JSON format as output from:

ldcli dev-server get-project --project=<key> \
  --expand=overrides --expand=availableVariations

This enables a simple export/import workflow:

# Export
ldcli dev-server get-project --project=my-project \
  --expand=overrides --expand=availableVariations > backup.json

# Import via new API endpoint
curl -X POST http://localhost:8765/dev/projects/my-project/import \
  -H "Content-Type: application/json" \
  -d @backup.json

ajworkos and others added 2 commits February 12, 2026 14:18
Add POST /projects/{projectKey}/import endpoint to the dev server API
that allows importing a project from JSON data. This provides HTTP API
parity with the existing CLI import-project command.

Changes:
- Add /projects/{projectKey}/import endpoint to OpenAPI spec
- Regenerate server.gen.go with new endpoint types
- Implement PostImportProject handler that reuses model.ImportProject()
- Validates required fields (sourceEnvironmentKey, flagsState)
- Returns 409 Conflict if project already exists
- Returns 400 Bad Request for missing fields
- Returns 201 Created with project data on success

The endpoint accepts the same JSON format as output from:
  ldcli dev-server get-project --project=<key> \
    --expand=overrides --expand=availableVariations

This enables programmatic project imports and UI integration.

Co-authored-by: Cursor <cursoragent@cursor.com>
Use the Project schema for the import endpoint request body instead of
defining a custom schema with explicit required fields. This makes it
clear that the import endpoint accepts the same JSON format that the
export (get-project) endpoint produces.

Changes:
- Update api.yaml to use Project schema ref for import request body
- Regenerate server.gen.go with simplified type alias
- Update handler to properly handle nullable FlagsState pointer
- Add description clarifying the endpoint accepts exported JSON format

This aligns with the CLI import-project command which accepts the
exported JSON file directly without requiring individual field
specification.

Co-authored-by: Cursor <cursoragent@cursor.com>
@ajworkos
Copy link
Contributor Author

@nieblara wondering if you could look at this as you approved the last one (which has been working out fantastic 🎉). This was an oversight by me to not include the REST API

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant