Applications

APIs for managing applications are currently available for developers to preview. During the preview period, the API may change without advance notice.

Retrieve an application

GET /apps/:id

Based on the application id provided, returns the applications information.

Curl request

curl -H "Content-Type: application/json" -H "x-auth-token: <API Token>" --request GET https://api.codemagic.io/apps/<app_id>

Response

{
  "application": {
    "_id": "5d85eaa0e941e00019e81bc2",
    "appName": "counter_flutter",
    "branches": [
      "master"
    ],
    "workflowIds": [
      "5d85f242e941e00019e81bd2"
    ],
    "workflows": {
      "5d85f242e941e00019e81bd2": {
        "name": "Android Workflow"
      }
    }
  }
}

Add a new application

POST /apps

Adds a Git repository to the applications list.

Parameters

NameTypeDescription
repositoryUrlstringRequired. SSH or HTTPS URL for cloning the repository.
teamIdstringOptional. ID of a team if you wish to add an app directly to one of your teams. You must be an owner of the team specified.

Example

{
  "repositoryUrl": "git@github.com:my-organization/my-repo.git"
}

Response

{
  "_id": "5c9c064185dd2310123b8e96",
  "appName": "my-repo"
}

Add a new application from private repository

POST /apps/new

Creates an application from a private repository with SSH key

Parameters

NameTypeDescription
repositoryUrlstringRequired. SSH or HTTPS URL for cloning the repository.
sshKeyJSONRequired.
projectTypestringflutter-app when adding Flutter application.
teamIdstringOptional. ID of a team if you wish to add an app directly to one of your teams. You must be an owner of the team specified.

sshKey parameter

NameTypeDescription
datastringRequired. base64-encoded private key file.
passphrasestringRequired. SSH key passphrase or null if it SSH key is without passphrase.

To encode private key file and paste result to clipboard

base64 id_rsa | pbcopy

Example

{
  "repositoryUrl": "git@github.com:my-organization/my-repo.git",
  "sshKey": {"data": "St89hgb-BASE64-ENCODED-SSH-KEY-FILE-H4ga7jgf==", "passphrase": null}
}

Response

{"application" : {
  "_id": "5c9c064185dd2310123b8e96",
  "appName": "my-repo"
}}

Encrypt an environment variable

POST /apps/:id/encrypt-environment-variable

Generates an encrypted string that will be decrypted inside our machines when building the app. It can be used in YAML environment variables without exposing the plain text content in version control.

Note that the variables will need to be re-generated when moving the app to a different team.

CURL example

curl 'https://api.codemagic.io/apps/your-app-id/encrypt-environment-variable' \
 -H 'X-Auth-Token: your-token' \
 -H 'Content-Type: application/json;charset=utf-8' \
 --data '{"value": "your value"}'

Response

{"encrypted": "Encrypted(Z0FBQUFBQmZMVkhwb3Q3QlJtRlVOeVFJcEJvTTRtWnZablpqMS0xN2V6dllTell1ODZSd2FUcnNqMUlZT09QY1paV0pjbVRfUlVJeDUxRWIzX1paOEZlc1dSdi1XMXlkUFVIdjNIZ2VqcE5Ja0tpMjlPWjhlSTQ9)"}