# Resolve sync issues

> Retry, revert or ignore issues: the ones listed by id, or with `all_issues: true` every issue of a sync or of one of its tables. Retrying writes the change again; reverting restores the record from the destination app; ignoring closes the issue.

Source: https://docs.stacksync.com/api-reference/syncs/issues/resolve_sync_issues

`POST https://api.stacksync.com/v1/workspaces/{workspace_id}/issues/action`

- Operation: `resolve_sync_issues`
- Resource: Sync issues
- Access: writes data

## Authentication

- `Authorization: Bearer <key>`: A workspace API key (workspace_…, created by a workspace owner under Workspace settings > Stacksync API) acts with editor rights on that workspace only; a user API key (user_…, created under Profile > Stacksync API) acts as that user in every workspace they belong to. POST, PUT and PATCH requests must send Content-Type: application/json. Every authentication failure answers 403.
- `Content-Type: application/json` on every request with a body.

## Path parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `workspace_id` | integer | Yes | The workspace the resources belong to |

## Query parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `region` | string (besg \| usnv) | Yes | Data region of the syncs |

## Request body

`application/json`. The issues and the action

One of: object (ResolveListedSyncIssuesBody). Act on the issues listed by id

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `ids` | array of string (uuid), at least 1 item | Yes | The issues, every id must exist in the workspace |
| `action` | string (retry \| ignore \| revert) | Yes | `retry` writes the change again, `revert` restores the record from the destination app, `ignore` closes the issue |

Or: object (ResolveAllSyncIssuesBody). Act on every issue of a sync, or of one of its tables (`ids` must not be sent)

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `all_issues` | boolean (true) | Yes | True |
| `base_id` | string (uuid) | Yes | The sync, in the region of the request |
| `table_id` | string | No | Only the issues of this table pair (its `table_mapping_id`); every table when left out |
| `action` | string (retry \| ignore \| revert) | Yes | `retry` writes the change again, `revert` restores the record from the destination app, `ignore` closes the issue |

## Returns

### 200 What the action did

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `data` | object (ResolvedSyncIssues) | Yes | What the action did |
| `data.ids` | array of string (uuid) | Yes | The issues acted on; empty for `all_issues` |
| `data.success_issue_count` | integer | Yes | Issues resolved |
| `data.failed_issue_count` | integer | Yes | Issues that could not be resolved |
| `data.error_list` | array of object | Yes | Why each failed issue failed |

## Example request

One of: Act on the issues listed by id

```bash
curl -X POST "https://api.stacksync.com/v1/workspaces/{workspace_id}/issues/action?region=besg" \
  -H "Authorization: Bearer $STACKSYNC_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "ids": [
    "4c5d6e7f-8a9b-4c0d-9e1f-2a3b4c5d6e7f"
  ],
  "action": "retry"
}'
```

Or: Act on every issue of a sync (ids must not be sent)

```bash
curl -X POST "https://api.stacksync.com/v1/workspaces/{workspace_id}/issues/action?region=besg" \
  -H "Authorization: Bearer $STACKSYNC_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "all_issues": true,
  "base_id": "3f6c1d2e-8a4b-4c7d-9e21-5b6f7a8c9d01",
  "action": "retry"
}'
```

## Example response (200)

```json
{
  "data": {
    "ids": [
      "4c5d6e7f-8a9b-4c0d-9e1f-2a3b4c5d6e7f"
    ],
    "success_issue_count": 1,
    "failed_issue_count": 0,
    "error_list": []
  }
}
```

## Errors

| Status | Meaning | Body |
| --- | --- | --- |
| 400 | The `region` is missing or not one of besg, usnv; the body is not valid JSON; `ids` is missing, empty or holds a non-UUID, `action` is not retry, ignore or revert, `all_issues` is sent with `ids` or without a UUID `base_id` (`Invalid Request Body`); an id names no issue of the workspace (`Invalid error ids.`, the message lists them); the issues of the sync could not be read (`Error retrieving issues`) | `{ "error": string }` |
| 403 | Forbidden: invalid API key, API key of another workspace, insufficient scope, workspace unavailable, or a non-GET request without `Content-Type: application/json` | `{ "error": string }` |
| 404 | The workspace has no sync with issues to act on (`issues not found`), or `base_id` of `all_issues` is not a sync of the workspace in this region (`Base not found`) | `{ "error": string }` |

## Related

- [API Reference overview](https://docs.stacksync.com/api-reference): base URLs, regions, pagination, idempotency and errors
- [Authentication](https://docs.stacksync.com/api-reference/authentication): API keys and the 403 answers
- OpenAPI document: https://docs.stacksync.com/openapi.json
- [List sync issues](https://docs.stacksync.com/api-reference/syncs/issues/list_sync_issues)