---
title: "Import automation results"
method: POST
path: "/automation"
tags: ["Automation"]
---

# Import automation results

`POST /automation`

## Request

- Base URL: `https://app.testiny.io/api/v1`
- URL: `https://app.testiny.io/api/v1/automation`
- Auth: API key in header `X-Api-Key`
- TypeScript: <https://skmtc.dev/testiny/apis/testiny-api/docs/automation/post.ts> (a function with typed inputs; its response is checked against the schema)

Import automated test results, automatically creating sources, test cases, test runs and test results

## Request body

- AutomationResults
  - `projectId` number, required: Project id to import into
  - `source` string, required: Automation source name (e.g. myproject-unit)
  - `runGroupBy` string[]: Field names whose values group results into test runs
  - `results` AutomationResultItem[], required: List of results to import
    - `ts` integer: Optional timestamp in epoch-milliseconds. Current time if omitted
    - `title` string: Test case title - required if test case key is not present
    - `key` string: Test case key, a short unique identifier - required if test case title is not present
    - `path` string[]: Optional list of folder/suite paths for test case organization and identification
    - `duration` number: Optional duration in seconds
    - `status` 'passed' | 'passed_warn' | 'failed' | 'blocked' | 'skipped', required: The result status from the list of allowed values
    - `error` string: A short error message if an error occurred
    - `detailMessage` string: A detailed message or error stack trace if an error occurred
    - `errorLocation` object: Metadata about the error location e.g. file,line,steps etc.
      - `file` string: The source file name where the error occurred, should be relative to repository root
      - `line` integer: Source line, starts with 1
      - `column` integer: Source column, starts with 1
      - `step` string: The name or id of the test step where the error occurred
    - `attachments` AutomationAttachment[]
      - `refId` string, required
      - `file` string, required
      - `type` string, required
      - `title` string
    - `fields` union[], required: Automation field values
      - union
        - string
        - number
        - boolean
    - `steps` object[]
      - `id` string
      - `title` string, required
  - `fieldNames` string[], required: Automation field names
  - `runTitlePattern` string: Test run title pattern, with %{field_name} placeholders (%% escapes a percent)
  - `noFieldCreate` boolean: Do not ad-hoc create fields if they don't exist
  - `noSourceCreate` boolean: Do not ad-hoc create sources if they don't exist
  - `useServerTime` boolean: All ingested results are timestamped with current server time
  - `milestoneId` integer: Link newly created automation runs to the milestone with the given id

## Response `200`

Returns 'AutomationSubmitResult'

- AutomationSubmitResult
  - `preparedAttachments` object[]: A list of prepared attachments - use blobId to upload content from files
    - `blobId` number, required: The entity id of the Blob for uploading data
    - `refId` string, required: User-defined value passed on import as refId for this attachment
    - `file` string, required: The file name/path for this attachment
    - `title` string: An optional title for the attachment (for reference)
  - `automationRunIds` integer[], required: A list of test run ids which were created or updated from the imported test results
  - `skippedResultIndices` integer[], required: A list of result indices from the import batch which where skipped because of completed or closed test runs

## Other responses

- `4XX`: The request failed because invalid request parameters or data were supplied or access was denied.
- `5XX`: The request failed because an error occurred during processing of the request.

---

[API](https://skmtc.dev/testiny/apis/testiny-api.md) - [All operations](https://skmtc.dev/testiny/apis/testiny-api/llms.txt) - [OpenAPI document](https://skmtc.dev/testiny/apis/testiny-api/revisions/8f7643b2429d?raw)
