Test creation

On this page

This section explains how to create tests by running a Test Suite within a project.
Both single Test Suite execution and multiple Test Suite execution APIs are covered.

Single test suite execution

Run a Test Suite in the specified project by sending an execution request.

Endpoint

[POST] /openapi/v3/projects/{pid}/test-suite-runs

Authorization

This API requires Basic Authentication using a combination of username and access_key.

KeyTypeRequiredDefaultDescription
auth(username, access_key)Yes–Encrypted login credentials. Required for every API call.
usernamestringYes–Ptero login ID.
access_keystringYes–Access Key
(not your password).
Issued in
Ptero › Top-right icon
› Edit Profile › Access Key.

Note
Encode the string username:access_key in Base64 and include it in the Authorization header.

Path parameter

You must include the project ID in the API path.

KeyTypeRequiredDefaultDescription
pidintYes–Project ID.

Request body

Content-Type: multipart/form-data

When running a test, include the Test Suite ID and app information in the request body.

Request body
- test_suite_id: int
- device: str | None 
- os: "ANDROID" | "iOS"
- source_type: "app_id" | "file" | None
- app_file: bytes | None
- app_download_url: str | None
- app_id: str | None
KeyTypeRequiredDefaultDescription
test_suite_idintYes–ID of the Test Suite to run.
devicestring | NoneNo“random_device”Target device. “random_device” selects one from available devices.
os“ANDROID” | “iOS”Yes–Operating system of the device. Case sensitive.
source_type“app_id” | “file” | NoneNo–How the app is provided
(by ID or file).
app_filebytes | NoneNo–Application file.
– Android: .apk, .apks, .xapk
– iOS: .ipa
app_download_urlstring | NoneNo–Application download URL. Must start with
http:// or https://.
app_idstring | NoneNo–Application ID.
– Android: package name
– iOS: bundle ID

Constraints

  • Only one of the following fields can be provided:
    • source_type
    • app_file
    • app_download_url
    • app_id
  • If two or more of these fields are included, a value error occurs.

Request example (cURL)

Run with project-registered app

cURL
curl -X POST "https://app.apptest.ai/api/openapi/v3/projects/123/test-suite-runs" \
  -H "Authorization: Basic $(echo -n 'johndoe:1q2w3e4r' | base64)" \
  -F "test_suite_id=112233" \
  -F "os=iOS" \
  -F "source_type=app_id"

Note

  • Authorization must be Base64 encoded (username:access_key).
  • If no device is specified, random_device is applied automatically.
  • OS must be uppercase; in iOS, only i is lowercase.
  • Test creation fails if no matching app exists in the project.

Run with app file upload and specific device

cURL
curl -X POST "https://app.apptest.ai/api/openapi/v3/projects/123/test-suite-runs" \
  -H "Authorization: Basic $(echo -n 'johndoe:1q2w3e4r' | base64)" \
  -F "test_suite_id=112233" \
  -F "device=SAMSUNG GALAXY NOTE8 / ANDROID 9" \
  -F "os=ANDROID" \
  -F "app_file=@/upload/your/file/path.apk"

Note

  • Authorization must be Base64 encoded (username:access_key).
  • test_suite_id specifies the Test Suite to execute.
  • device is explicitly set to SAMSUNG GALAXY NOTE8 / ANDROID 9.
  • os must be uppercase.
  • app_file must use one of the following extensions: .apk, .apks, .xapk, .ipa.

Run with app ID and random device

cURL
curl -X POST "https://app.apptest.ai/api/openapi/v3/projects/123/test-suite-runs" \
  -H "Authorization: Basic $(echo -n 'johndoe:1q2w3e4r' | base64)" \
  -F "test_suite_id=112233" \
  -F "device=random_device" \
  -F "os=ANDROID" \
  -F "app_id=com.android.chrome"

Note

  • Authorization must be Base64 encoded (username:access_key).
  • test_suite_id specifies the Test Suite to execute.
  • If device is not provided, it defaults to random_device.
  • os must be uppercase.

Output

content-type: application/json

Success response

JSON
{
  "error_code": 0,
  "reason": "",
  "result": "success",
  "data": {
    "session_id": 123456,
    "test_suite_run_id": 789012,
    "test_run_count": 5
  }
}
  • session_id – Identifier of the API call. Use this to check execution status or progress.
  • test_suite_run_id – Identifier of the Test Suite execution result. Use this to retrieve results at the Test Suite level.
  • test_run_count – Number of individual test runs generated from the Test Suite.

Error response

error_codereasondescription
401Could not verify your access levelUser not registered or invalid credentials.
V001Invalid valueInvalid request value (e.g., string passed for test_suite_id).
N001Just one application is allowedMore than one app field provided.
V003Invalid project IDProject does not exist.
A002Access denied for projectNo access rights to the project.
V008Invalid test suite IDTest Suite does not exist.
M001Invalid app file : System app file can not be testedSystem app file submitted.
M002app file info extraction errorFailed to extract app file metadata.
M003invalid app file extensionUnsupported app file extension.
A006Too many tests in accountTest creation limit exceeded (data.allowed_test_creation_count included).
V004Invalid scenario IDScenario does not exist (data.invalid_scn_ids included).
S006Scenario file is Invalid or corrupted while getting test dataScenario file missing or corrupted (data.not_exist_scns_file provided).
M006Device info does not existDevice information missing or list not retrieved.
M007Project settings app info is EmptyNo app matches the provided source_type in the project.
M008Invalid app idapp_id is empty or exceeds 100 characters.
A007The service is currently under system maintenanceService under maintenance.
E0001Internal Server ErrorServer-side error.
Example 1: authentication failed

This error occurs when the user information is invalid or the provided Access Key is incorrect.

JSON
{
  "response": "Could not verify your access level for that URL.",
  "status": 401,
  "headers": {
    "WWW-Authenticate": "Basic realm=\"Access key Required\""
  }
}
Example 2: V001 error (invalid value)

This error occurs when a string is provided for the test_suite_id field, which requires an integer.

JSON
{
  "data": [],
  "detail": {
    "errors": [
      {
        "input": "abc",
        "loc": ["test_suite_id"],
        "msg": "Input should be a valid integer, unable to parse string as an integer",
        "type": "int_parsing",
        "url": "https://errors.pydantic.dev/2.7/v/int_parsing"
      }
    ]
  },
  "errorCode": "V001",
  "error_code": "V001",
  "reason": "Invalid value",
  "result": "fail"
}

Multiple test suite execution

Run multiple Test Suites in a project with a single request.

  • Provide a test_suite_ids array to run tests in the given order.
  • If test_suite_ids is omitted, all Test Suites in the project are executed in alphabetical order by name.

Warning: If `test_suite_ids` is omitted, every Test Suite in the project will be executed.

Endpoint

[POST] /openapi/v3/projects/{pid}/multi-test-suite-runs

Authorization

This API requires Basic Authentication using a combination of username and access_key.

KeyTypeRequiredDefaultDescription
auth(username, access_key)Yes–Encrypted login credentials. Required for every API call.
usernamestringYes–Ptero login ID.
access_keystringYes–Access Key
(not your password).
Issued from
Ptero › Top-right icon
› Edit Profile › Access Key.

Note
Encode the string username:access_key in Base64 and include it in the Authorization header.

Path parameter

KeyTypeRequiredDefaultDescription
pidintYes–Project ID. Must be included in the API path.

Request body

Content-Type: multipart/form-data

When running tests, include the Test Suite and application information in the request body.

Request body
- test_suite_id: int
- device: str | None
- os: "ANDROID" | "iOS"
- source_type: "app_id" | "file" | None
- app_file: bytes | None
- app_download_url: str | None
- app_id: str | None
KeyTypeRequiredDefaultDescription
test_suite_idslist[int]No–List of Test Suite IDs to execute, in the given array order. If omitted, all Test Suites in the project are executed in alphabetical order.
devicestring | NoneNo“random_device”Target device. If not specified, a random available device is used.
os“ANDROID” | “iOS”Yes–Operating system of the device. Case sensitive.
source_type“app_id” | “file” | NoneNo–How the app is provided
(by ID or file).
app_filebytes | NoneNo–Application file.
– Android: .apk, .apks, .xapk
– iOS: .ipa only
app_download_urlstring | NoneNo–Application download URL. Must start with http:// or https://.
app_idstring | NoneNo–Application ID.
– Android: package name
– iOS: bundle ID

Constraints

  • Only one of the following fields can be provided:
    • app_id
    • app_file
    • app_download_url
    • source_type
  • If two or more of these fields are included in a request, a value error occurs.

Request example (cURL)

Run all test suites

cURL
curl -X POST "https://app.apptest.ai/api/openapi/v3/projects/123/multi-test-suite-runs" \
  -H "Authorization: Basic $(echo -n 'johndoe:1q2w3e4r' | base64)" \
  -F "os=iOS" \
  -F "source_type=app_id"

Note

  • Authorization header must include Base64-encoded username:access_key.
  • os must be uppercase; in iOS, only i is lowercase.
  • If test_suite_ids is not provided, all Test Suites in the project are executed in alphabetical order by name.
  • If device is not provided, random_device is assigned automatically.
  • Test creation fails if no app in the project matches both os and source_type.

Run specific test suites

cURL
curl -X POST "https://app.apptest.ai/api/openapi/v3/projects/123/multi-test-suite-runs" \
  -H "Authorization: Basic $(echo -n 'johndoe:1q2w3e4r' | base64)" \
  -F "test_suite_ids=[112233, 445566, 778899]" \
  -F "device=SAMSUNG GALAXY NOTE8 / ANDROID 9" \
  -F "os=ANDROID" \
  -F "app_file=@/upload/your/file/path.apk"

Note

  • Authorization header must include Base64-encoded username:access_key.
  • test_suite_ids runs the Test Suites in the specified array order.
  • If a device is provided, tests are executed on that device.
  • os must be uppercase.
  • When using app_file, tests run based on the uploaded application file. Supported extensions: .apk, .apks, .xapk, .ipa.

Run all test suites

cURL
curl -X POST "https://app.apptest.ai/api/openapi/v3/projects/123/multi-test-suite-runs" \
  -H "Authorization: Basic $(echo -n 'johndoe:1q2w3e4r' | base64)" \
  -F "device=random_device" \
  -F "os=ANDROID" \
  -F "app_id=com.android.chrome"

Note

  • Authorization header must include Base64-encoded username:access_key.
  • If test_suite_ids is not provided, all Test Suites in the project are executed in alphabetical order by name.
  • device=random_device executes tests on a randomly available device.
  • os must be uppercase.
  • app_id runs tests using the registered application ID (e.g., com.android.chrome).

Output

content-type: application/json

Success response

JSON
{
  "error_code": 0,
  "reason": "",
  "result": "success",
  "data": {
    "session_id": 123456,
    "test_suite_runs": [
      {
        "test_suite_run_id": 11111,
        "test_run_count": 5
      },
      {
        "test_suite_run_id": 22222,
        "test_run_count": 3
      }
    ],
    "total_test_run_count": 8
  }
}
  • session_id – Identifier of the API call. Use this to query execution status or results later.
  • test_suite_runs – List of individual Test Suite execution results, including test_suite_run_id and test_run_count.
  • total_test_run_count – Total number of test runs created from the entire request.

Note
session_id is an identifier of the multiple Test Suite execution results.
To learn more, see Test result lookup.

Error response

error_codereasondescription
401Could not verify your access levelUser not registered or invalid credentials.
V001Invalid valueInvalid request value (e.g., string passed for test_suite_ids).
V003Invalid project IDProject does not exist.
A002Access denied for projectNo access rights to the project.
C007test suite does not exist in projectNo Test Suite exists in the project.
M001Invalid app file : System app file can not be testedSystem app file submitted.
M002app file info extraction errorFailed to extract metadata from the app file.
M003invalid app file extensionUnsupported app file extension.
A006Too many tests in accountTest creation limit exceeded (data.allowed_test_creation_count included).
V004Invalid scenario IDScenario does not exist (data.invalid_scn_ids included).
S006Scenario file is Invalid or corrupted while getting test dataScenario file missing or corrupted (data.not_exist_scns_file provided).
M006Device info does not existDevice information missing or list not retrieved.
M007Project settings app info is EmptyNo app matches the provided source_type in the project.
M008Invalid app idapp_id is empty or exceeds 100 characters.
A007The service is currently under system maintenanceService under maintenance.
E0001Internal Server ErrorServer-side error.

Refer to Single Test Suite Run > Error Response Example for the error response format.