## Retrieve a sequence test

`client.Sequence.GetTest(ctx, testID, query) (*SequenceRetrieveTestResponse, error)`

**get** `/v1/sequences/{id}/tests/{testId}`

Retrieves the result of a test started with [Start a sequence test](/api/resources/sequence/methods/startTest): its status, and for every step of the tested version whether it composed a message, was skipped or failed. Poll it until `status` is `COMPLETED` or `FAILED`.

An email step’s message is its subject and a markdown body, and a LinkedIn step’s message is its text. A step that failed carries the reason under `error`; a template step whose variable could not be filled for the contact fails this way, naming the fields. Steps that have not run are `PENDING`, including a step a finished test never reached; a step that produced nothing is `SKIPPED`. A test never waits, so a wait is always `SKIPPED`; a send step is `SKIPPED` when it has nothing to send, such as a LinkedIn invite another step already sent. A test never sends anything.

Returns 404 for a test that does not exist, belongs to another sequence, or is a live enrollment: use [Retrieve a sequence enrollment](/api/resources/sequence/methods/retrieveEnrollment) for those.

**[Required scope](/using-the-api/scopes/):** `sequences:read`

**[Rate limit category](/using-the-api/rate-limits/):** Read

### Parameters

- `testID string`

  The `id` returned when the test was started.

- `query SequenceGetTestParams`

  - `ID param.Field[string]`

    Unique identifier of the sequence.

### Returns

- `type SequenceRetrieveTestResponse struct{…}`

  - `ID string`

    ID of the test, an enrollment ID.

  - `ContactID string`

    ID of the contact tested.

  - `Status SequenceRetrieveTestResponseStatus`

    `RUNNING` until every step has finished, then `COMPLETED`, or `FAILED` when the test ended on a failure.

    - `const SequenceRetrieveTestResponseStatusRunning SequenceRetrieveTestResponseStatus = "RUNNING"`

    - `const SequenceRetrieveTestResponseStatusCompleted SequenceRetrieveTestResponseStatus = "COMPLETED"`

    - `const SequenceRetrieveTestResponseStatusFailed SequenceRetrieveTestResponseStatus = "FAILED"`

  - `Steps []SequenceRetrieveTestResponseStep`

    Every step of the tested version that the Sequences API lists, in run order. Call steps are not part of the API yet, so a test reports nothing for them.

    - `Error SequenceRetrieveTestResponseStepError`

      Why the step failed; null unless `outcome` is `FAILED`.

      - `Code string`

        `CONFIGURATION_ERROR` when the sequence or the contact needs a change, `SYSTEM_ERROR` when Lightfield failed.

        - `const SequenceRetrieveTestResponseStepErrorCodeConfigurationError SequenceRetrieveTestResponseStepErrorCode = "CONFIGURATION_ERROR"`

        - `const SequenceRetrieveTestResponseStepErrorCodeSystemError SequenceRetrieveTestResponseStepErrorCode = "SYSTEM_ERROR"`

      - `Message string`

        What went wrong, in plain words.

    - `Message SequenceRetrieveTestResponseStepMessageUnion`

      The composed message; null when the step has not composed one.

      - `type SequenceRetrieveTestResponseStepMessageEmailMessage struct{…}`

        - `Body string`

          Body as markdown, the same form a template step reads back in.

        - `Subject string`

          Subject line, as composed.

      - `type SequenceRetrieveTestResponseStepMessageLinkedInMessage struct{…}`

        - `Body string`

          Message text, as composed.

    - `Mode string`

      How a send step’s content is composed; null for a wait step.

      - `const SequenceRetrieveTestResponseStepModeAgent SequenceRetrieveTestResponseStepMode = "AGENT"`

      - `const SequenceRetrieveTestResponseStepModeTemplate SequenceRetrieveTestResponseStepMode = "TEMPLATE"`

    - `Name string`

      Name of the step, as in `definition.steps`; null for a wait step.

    - `Outcome string`

      `PENDING` while the step has not run, including a step a finished test never reached, `COMPOSED` when it produced a message, `SKIPPED` when it produced nothing: a test never waits, so a wait is always `SKIPPED`, and a send step is `SKIPPED` when it has nothing to send, such as a LinkedIn invite another step already sent. `FAILED` when it failed: see `error`.

      - `const SequenceRetrieveTestResponseStepOutcomePending SequenceRetrieveTestResponseStepOutcome = "PENDING"`

      - `const SequenceRetrieveTestResponseStepOutcomeComposed SequenceRetrieveTestResponseStepOutcome = "COMPOSED"`

      - `const SequenceRetrieveTestResponseStepOutcomeSkipped SequenceRetrieveTestResponseStepOutcome = "SKIPPED"`

      - `const SequenceRetrieveTestResponseStepOutcomeFailed SequenceRetrieveTestResponseStepOutcome = "FAILED"`

    - `StepID string`

      ID of the step, as in the sequence’s `definition.steps`.

    - `Type string`

      Step type.

      - `const SequenceRetrieveTestResponseStepTypeEmail SequenceRetrieveTestResponseStepType = "EMAIL"`

      - `const SequenceRetrieveTestResponseStepTypeLinkedinMessage SequenceRetrieveTestResponseStepType = "LINKEDIN_MESSAGE"`

      - `const SequenceRetrieveTestResponseStepTypeLinkedinInvite SequenceRetrieveTestResponseStepType = "LINKEDIN_INVITE"`

      - `const SequenceRetrieveTestResponseStepTypeWait SequenceRetrieveTestResponseStepType = "WAIT"`

      - `const SequenceRetrieveTestResponseStepTypeWaitForConnection SequenceRetrieveTestResponseStepType = "WAIT_FOR_CONNECTION"`

  - `Target SequenceRetrieveTestResponseTarget`

    Which version was tested.

    - `const SequenceRetrieveTestResponseTargetDraft SequenceRetrieveTestResponseTarget = "DRAFT"`

    - `const SequenceRetrieveTestResponseTargetPublished SequenceRetrieveTestResponseTarget = "PUBLISHED"`

### Example

```go
package main

import (
  "context"
  "fmt"

  "github.com/Lightfld/lightfield-go"
  "github.com/Lightfld/lightfield-go/option"
)

func main() {
  client := githubcomlightfldlightfieldgo.NewClient(
    option.WithAPIKey("My API Key"),
  )
  sequenceRetrieveTestResponse, err := client.Sequence.GetTest(
    context.TODO(),
    "testId",
    githubcomlightfldlightfieldgo.SequenceGetTestParams{
      ID: "id",
    },
  )
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", sequenceRetrieveTestResponse.ID)
}
```

#### Response

```json
{
  "id": "id",
  "contactId": "contactId",
  "status": "RUNNING",
  "steps": [
    {
      "error": {
        "code": "CONFIGURATION_ERROR",
        "message": "message"
      },
      "message": {
        "body": "body",
        "subject": "subject"
      },
      "mode": "AGENT",
      "name": "name",
      "outcome": "PENDING",
      "stepId": "stepId",
      "type": "EMAIL"
    }
  ],
  "target": "DRAFT"
}
```
