How do I trigger builds and pass dynamic configuration using the Codemagic API v3?

Last updated: October 5, 2026

Context

Previously, some users relied on the older Codemagic API to update app settings (such as environment variables, build arguments, or repository credentials) before triggering a build. With the transition to API v3, the endpoint structure and request format have changed, and calls to the old API endpoints will return a 400 Bad Request error.

Answer

In API v3, you no longer need a separate "update" request before triggering a build. Instead, you can pass environment variables and dynamic configuration directly in the build trigger request.

To trigger a build with dynamic variables, send a POST request to:

POST https://api.codemagic.io/api/v3/apps/{app_id}/builds

Include your dynamic values under the environment.variables field in the payload:

{
  "workflowId": "your-workflow-id",
  "branch": "main",
  "environment": {
    "variables": {
      "TARGET_FILE": "lib/app/flavors/main_staging.dart",
      "FLAVOR": "DEV",
      "EXTRA_ARGS": "--dart-define=APP_VERSION=1.0.0 --dart-define=APP_ID=com.example.app"
    }
  }
}

In your workflow YAML, reference these variables as placeholders in your build scripts. For example:

flutter build ipa -t $TARGET_FILE --flavor $FLAVOR $EXTRA_ARGS

This approach replaces the previous method of directly overriding UI buildSettings paths (e.g., buildSettings.iosBuildArguments) via API, which is not supported in v3.

Updating repository credentials: In API v3, there is currently no endpoint to programmatically update an app's repository connection details or credentials (such as URL or password). These changes must be made manually in the Codemagic UI under App Settings > Repository Settings.

For a full reference of all available API v3 endpoints and request structures, see the Codemagic API v3 Schema.