> For the complete documentation index, see [llms.txt](https://docs.pyck.cloud/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.pyck.cloud/graphql-api/queries/workflowtargets.md).

# WorkflowTargets

Read the current target surfaces of a workflow execution

Audience: Programmer

Reads the current target surfaces of a single workflow execution. Returns an empty list when the workflow has not declared any targets.

The target surfaces are stored in the `pyck_workflow_targets` KeywordList search attribute in Temporal and represent the client surfaces (such as web, mobile, or setup) for which the workflow is intended.

## Arguments

| Name    | Type                       | Description                                      |
| ------- | -------------------------- | ------------------------------------------------ |
| `input` | `GetWorkflowTargetsInput!` | Input containing workflow identifiers (required) |

### GetWorkflowTargetsInput Fields

| Field                 | Type      | Description                                   |
| --------------------- | --------- | --------------------------------------------- |
| `workflowId`          | `String!` | The unique identifier of the workflow         |
| `workflowExecutionId` | `String!` | The specific run ID of the workflow execution |

## Return Type

`GetWorkflowTargetsResponse!` - Response containing the list of target surfaces (non-nullable).

### GetWorkflowTargetsResponse Fields

| Field     | Type                 | Description                                                                    |
| --------- | -------------------- | ------------------------------------------------------------------------------ |
| `targets` | `[WorkflowTarget!]!` | The list of currently declared target surfaces. Empty when no targets are set. |

## Usage Example

### GraphQL Query

```graphql
query GetWorkflowTargets {
  workflowTargets(input: {
    workflowId: "picking-order-12345"
    workflowExecutionId: "run-abc-123"
  }) {
    targets
  }
}
```

### JavaScript Example

```javascript
const query = `
  query GetWorkflowTargets($input: GetWorkflowTargetsInput!) {
    workflowTargets(input: $input) {
      targets
    }
  }
`;

const variables = {
  input: {
    workflowId: "picking-order-12345",
    workflowExecutionId: "run-abc-123"
  }
};

const response = await fetch('/graphql', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'Authorization': `Bearer ${token}`
  },
  body: JSON.stringify({
    query,
    variables
  })
});

const result = await response.json();
console.log('Targets:', result.data.workflowTargets.targets);
// Output: [ 'WEB', 'MOBILE' ]
```

## Response Example

### Workflow with Targets Declared

```json
{
  "data": {
    "workflowTargets": {
      "targets": ["WEB", "MOBILE"]
    }
  }
}
```

### Workflow Without Targets

When no targets have been declared, the field returns an empty list:

```json
{
  "data": {
    "workflowTargets": {
      "targets": []
    }
  }
}
```

## Filtering Workflow Executions by Target

The targets exposed by this query are also indexed as the `pyck_workflow_targets` KeywordList search attribute. They can be combined with filtering queries:

```graphql
query {
  workflowExecutions(
    where: {
      targets: [WEB]
      status: "RUNNING"
    }
    first: 50
  ) {
    edges {
      node {
        execution {
          workflowId
          id
        }
      }
    }
  }
}
```

## Error Handling

The query may return errors in the following cases:

### Invalid WorkflowId

```json
{
  "errors": [{
    "message": "invalid WorkflowID",
    "path": ["workflowTargets"]
  }]
}
```

### Invalid WorkflowExecutionId

```json
{
  "errors": [{
    "message": "invalid WorkflowExecutionID",
    "path": ["workflowTargets"]
  }]
}
```

### Workflow Not Found

```json
{
  "errors": [{
    "message": "workflow not found: picking-order-12345",
    "path": ["workflowTargets"]
  }]
}
```

## Notes

* Targets are stored in Temporal's search attribute `pyck_workflow_targets` (KeywordList)
* An empty `targets` array is returned for workflows that have not declared any targets
* The query is read-only and does not affect the workflow execution
* Target values must be valid `WorkflowTarget` enum values (`WEB`, `MOBILE`, `SETUP`)
* Use [setWorkflowTargets](/graphql-api/mutations/setworkflowtargets.md) to update targets at runtime

## Related Documentation

* Mutation: [setWorkflowTargets](/graphql-api/mutations/setworkflowtargets.md)
* Input: [GetWorkflowTargetsInput](/graphql-api/inputs/getworkflowtargetsinput.md)
* Type: [GetWorkflowTargetsResponse](/graphql-api/types/getworkflowtargetsresponse.md)
* Enum: [WorkflowTarget](/graphql-api/enums/workflowtarget.md)
* Query: [workflowExecutions](/graphql-api/queries/workflowexecutions.md)

## Service

This query is provided by the **workflow** service as part of the federated GraphQL schema.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.pyck.cloud/graphql-api/queries/workflowtargets.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
