ReferenceFlightcontrol APIProjectsCreate Project

Create Project API

Use this API to automate the creation of a new project in your Flightcontrol account.

Prerequisites

To use the Create Project API, you must authenticate with an API key generated by a user who:

  1. Has at least the Developer role in the organization
  2. Has access to the git repository you are going to use
  3. And Flightcontrol must have access to that git repository through the GitHub or GitLab integration

API Description

MethodPath
POST/v1/projects
Headers
AuthorizationBearer: [API key]
Content-Typeapplication/json

Full Endpoint URL https://api.flightcontrol.dev/v1/projects

Body
ParameterTypeValuesRequiredDescription
namestringYesThe project name displayed in the Flightcontrol dashboard.
repoUrlstringYesThe URL of your Git repository.
awsAccountIdstringYesThe Flightcontrol unique id for the connected AWS account where your project will be deployed.
codeSourceobject: see below for detailYesThe Git provider configuration for your project.
configTypestring"gui", "iac"YesThe type of configuration to use for your project.
configobject: see below for detailRequired when configType is “gui”Contains project configuration.
configFilePathstringRequired when configType is “iac”Path to your configuration file.
configFileBranchstringRequired when configType is “iac”Branch containing your configuration file.

The config object

This object follows the Flightcontrol configuration schema used in the flightcontrol.json file, and is used to configure your project and allows you to configure and control the project in Flightcontrol’s dashboard.

The codeSource object

ParameterTypeValuesRequiredDescription
providerstring"github", "gitlab", "gitlab_self_hosted"YesThe Git provider to use for your project.
hoststringRequired when provider is “gitlab_self_hosted”The Self-Hosted GitLab instance host.

Response Example

{
  "id": "crkx7acm00003f6gobvidq2i",
  "organizationId": "cx7xb7acm00003f6gobvidq2i"
}

Response Conditions

Success

Errors

Guide to Creating and Deploying a New Project

Step 1: Create an AWS Account

Skip to step 3 if you already have an AWS account ID connected to Flightcontrol.

  1. Use the Create AWS Account API to create a new AWS account
curl --request POST \
  --url https://api.flightcontrol.dev/v1/aws-accounts \
  --header 'authorization: Bearer ${TOKEN}' \
  --header 'content-type: application/json' \
  --data '{
  "name": "My AWS Account"
}'
  1. The response will contain the connection stack link that you can use to connect your AWS account to Flightcontrol:
{
  "id": "cmadqj0k400000cjs6wwu2n5y",
  "name": "My AWS Account",
  "status": "AWAITING_CONNECTION",
  "cloudFormation": {
    "consoleUrl": "https://console.aws.amazon.com/cloudformation/home?region=us-east-1#/stacks/create/review?templateUrl=https://fc-public-cf-templates.s3.us-west-2.amazonaws.com/flightcontrol-cloudformation-v2.json",
    "template": {
      "url": "https://fc-public-cf-templates.s3.us-west-2.amazonaws.com/flightcontrol-cloudformation-v2.json",
      "stackName": "flightcontrol-access-cmadqj0k400000cjs6wwu2n5y",
      "region": "us-east-1",
      "parameters": {
        "FlightcontrolId": "cmadqj0k400000cjs6wwu2n5y"
      }
    }
  }
}
  1. Create the cloudformation stack in your AWS account to authenticate Flightcontrol
  1. Open the link in the cloudFormation.consoleUrl field of the response.
  2. Click on the “Create stack” button.
AWS Create Stack Button

Step 2: Wait for AWS Account to Be Connected

Use the Get AWS Account API to check the status of the AWS account.

curl --request GET \
  --url https://api.flightcontrol.dev/v1/aws-accounts/${AWS_ACCOUNT_ID} \
  --header 'Authorization: Bearer ${TOKEN}'

The response will contain the AWS account status:

{
  "status": "CONNECTED"
}

When the status is CONNECTED, you can proceed to the next step.

Step 3: Create a Project

  1. Create a project that will be configurable via the Flightcontrol dashboard.

        curl --request POST \
    --url https://api.flightcontrol.dev/v1/projects \
    --header 'Authorization: Bearer ${TOKEN}' \
    --header 'Content-Type: application/json' \
    --data '{
      "name": "My Project",
      "awsAccountId": "cm7xb7ocr000210k0cso2uo4d",
      "repoUrl": "https://github.com/org/repo",
      "codeSource": {
        "provider": "github"
      },
      "configType": "gui",
      "config": {"$schema":"https://app.flightcontrol.dev/schema.json","environments":[{"id":"production","name":"Lambda","region":"eu-south-1","source":{"branch":"main","pr":false,"trigger":"push"},"services":[{"ci":{"type":"ec2","storageIops":3000,"storageType":"gp3","instanceStorage":30,"storageThroughput":125},"id":"lambda-dev","name":"Lambda","type":"lambda-function","lambda":{"fnUrl":{"enabled":false},"memory":128,"packageType":"image","timeoutSecs":3},"basePath":".","buildType":"docker","envVariables":{},"dockerContext":".","dockerfilePath":"Dockerfile","includeEnvVariablesInBuild":true,"injectEnvVariablesInDockerfile":true}]}]}
    }'
    1. The response will contain the project details:
    {
      "id": "cm7xb7acm00003f6gobvidq2i",
      "organizationId": "cx7xb7acm00003f6gobvidq2i",
    }

Step 4: Deploy the Project

  1. Use the Create Deployment API to deploy the project.
curl --request POST \
  --url https://api.flightcontrol.dev/v1/deployments \
  --header 'Authorization: Bearer ${TOKEN}' \
  --header 'Content-Type: application/json' \
  --data '{
  "repoUrl": "https://github.com/org/repo",
  "branch": "main",
  "filter": {
    "projectId": "cm7xb7acm00003f6gobvidq2i"
  }
}'
  1. The response will contain the deployment details:
{
  "id": "cm7xb7acm00003f6gobvidq2i",
  "projectId": "cm7xb7acm00003f6gobvidq2i",
  "branch": "main",
  "commit": "02f153b"
}