# Automation

Automation rules: list and search their summaries, read one, switch it on or off, and run a manual rule on tasks or pages.

## List and search automation rules

`GET /orgs/{org}/automation/rules`

Scope: `automation:read`

Summaries of the rules you may read, as the automation pages list them, by name, cursor paged: organisation admins every rule; a project's or space's rule managers the rules they manage and, read only, the rules that reach it. Search by trigger, state, owner, or the project or space a rule reaches (for someone who manages its rules); Jira's Get and Search rule summaries. Someone who manages no rules gets 404, as the app hides its automation pages.

### Path parameters

- `org` (string, required): The organisation's id (or its address name). [1 to 100 characters]

### Query parameters

- `limit` (integer): How many items a page holds, 1 to 200. [from 1 to 200; default 50]
- `cursor` (string): The next_cursor of the previous page; leave it out for the first page. [at most 1000 characters]
- `count` (string): true adds total, the number of items in the whole list. [one of: true, false]
- `product` (string): Only projects' or Docs' rules. [one of: projects, docs]
- `project` (string): The rules that reach this project (its key). [1 to 40 characters]
- `space` (string): The rules that reach this Docs space (its key). [1 to 40 characters]
- `state` (string): Only rules on, or off. [one of: enabled, disabled]
- `trigger` (string): Only rules with this trigger (manual, task_created, …). [matches ^[a-z][a-z0-9_]{1,59}$]
- `owner` (string (uuid)): Only rules this person owns (their id).
- `name` (string): Only rules whose name has this. [1 to 255 characters]
- `fields` (string): Only these fields, comma-separated: id, number, name, product, kind, state, trigger, owner, scope, last_run, can_manage, updated_at. id always comes; the fields not asked for are left out, required or not.

### Request

```sh
curl -X GET "https://projqo.example/api/v1/orgs/{org}/automation/rules" \
  -H "Authorization: Bearer $PROJQO_TOKEN"
```

### Answer: 200

```json
{
  "items": [
    {
      "id": "7c8d9e0f-1a2b-4c3d-8e4f-5a6b7c8d9e0f",
      "number": 12,
      "name": "Close the parent when its subtasks are done",
      "product": "projects",
      "kind": "rule",
      "state": "enabled",
      "trigger": "task_transitioned",
      "owner": {
        "id": "8d0e5f7a-1c2b-4d3e-8f9a-0b1c2d3e4f5a",
        "name": "Priya Shah"
      },
      "scope": {
        "kind": "one",
        "family": null,
        "items": [
          {
            "kind": "project",
            "id": "3d4e5f6a-7b8c-4d9e-8f0a-1b2c3d4e5f6a",
            "key": "WEB",
            "name": "Website"
          }
        ]
      },
      "last_run": {
        "status": "success",
        "at": "2026-12-01T10:15:00.000Z"
      },
      "can_manage": true,
      "updated_at": "2026-11-28T08:00:00.000Z"
    }
  ],
  "next_cursor": null
}
```

### Errors

- 400 `invalid`: invalid: A value is wrong or missing, or a parameter is unknown. Every problem is in details.
- 401 `invalid_token`: invalid_token: No token was sent, or it is wrong, expired or revoked, or its person is no longer a member (or is now a guest).
- 403 `insufficient_scope`: insufficient_scope: The token doesn't have the scope this call needs (named in WWW-Authenticate). api_off: The organisation's admins have switched the API off. suspended: projqo has suspended the organisation.
- 404 `not_found`: not_found: Nothing is at this address, or the token's person can't see it: the answer is the same.
- 429 `rate_limited`: rate_limited: Too many calls in this minute, for the token or for the whole organisation.
- 500 `internal`: internal: Something went wrong on projqo's side (never your mistake).

## Get an automation rule

`GET /orgs/{org}/automation/rules/{rule}`

Scope: `automation:read`

One rule you may read, with its trigger, conditions and actions as the rule editor keeps them. A project or space in its scope that you can't open is left out.

### Path parameters

- `org` (string, required): The organisation's id (or its address name). [1 to 100 characters]
- `rule` (string, required): The rule's id, or its number (as the app shows it: Rule 12). [1 to 40 characters]

### Query parameters

- `fields` (string): Only these fields, comma-separated: id, number, name, product, kind, state, trigger, owner, scope, last_run, can_manage, updated_at, description, notify_on_error, edit_access, triggered_by, actor, definition, recurring, failing_since, created_at. id always comes; the fields not asked for are left out, required or not.

### Request

```sh
curl -X GET "https://projqo.example/api/v1/orgs/{org}/automation/rules/{rule}" \
  -H "Authorization: Bearer $PROJQO_TOKEN"
```

### Answer: 200

```json
{
  "id": "7c8d9e0f-1a2b-4c3d-8e4f-5a6b7c8d9e0f",
  "number": 12,
  "name": "Close the parent when its subtasks are done",
  "product": "projects",
  "kind": "rule",
  "state": "enabled",
  "trigger": "task_transitioned",
  "owner": {
    "id": "8d0e5f7a-1c2b-4d3e-8f9a-0b1c2d3e4f5a",
    "name": "Priya Shah"
  },
  "scope": {
    "kind": "one",
    "family": null,
    "items": [
      {
        "kind": "project",
        "id": "3d4e5f6a-7b8c-4d9e-8f0a-1b2c3d4e5f6a",
        "key": "WEB",
        "name": "Website"
      }
    ]
  },
  "last_run": {
    "status": "success",
    "at": "2026-12-01T10:15:00.000Z"
  },
  "can_manage": true,
  "updated_at": "2026-11-28T08:00:00.000Z",
  "description": "",
  "notify_on_error": true,
  "edit_access": "managers",
  "triggered_by": "people",
  "actor": {
    "kind": "automation",
    "person": null
  },
  "definition": {
    "version": 1,
    "trigger": {
      "key": "task_transitioned",
      "config": {}
    },
    "steps": []
  },
  "recurring": false,
  "failing_since": null,
  "created_at": "2026-11-20T08:00:00.000Z"
}
```

### Errors

- 400 `invalid`: invalid: A value is wrong or missing, or a parameter is unknown. Every problem is in details.
- 401 `invalid_token`: invalid_token: No token was sent, or it is wrong, expired or revoked, or its person is no longer a member (or is now a guest).
- 403 `insufficient_scope`: insufficient_scope: The token doesn't have the scope this call needs (named in WWW-Authenticate). api_off: The organisation's admins have switched the API off. suspended: projqo has suspended the organisation.
- 404 `not_found`: not_found: Nothing is at this address, or the token's person can't see it: the answer is the same.
- 429 `rate_limited`: rate_limited: Too many calls in this minute, for the token or for the whole organisation.
- 500 `internal`: internal: Something went wrong on projqo's side (never your mistake).

## Switch a rule on or off

`PATCH /orgs/{org}/automation/rules/{rule}`

Scope: `automation:write`

Changes the rule's state, as its switch in the app does, for those who manage it (Jira's Update rule state). Switching it on runs the app's check first: a rule with something to fix answers 409 conflict naming each problem. A rule already in that state stays as it is. Each switch is a rule change in the rule's run log. Changing anything else waits for a later release.

### Path parameters

- `org` (string, required): The organisation's id (or its address name). [1 to 100 characters]
- `rule` (string, required): The rule's id, or its number (as the app shows it: Rule 12). [1 to 40 characters]

### Body

- `state` (string, required) [one of: enabled, disabled]

### Request

```sh
curl -X PATCH "https://projqo.example/api/v1/orgs/{org}/automation/rules/{rule}" \
  -H "Authorization: Bearer $PROJQO_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
  "state": "enabled"
}'
```

### Answer: 200

```json
{
  "id": "7c8d9e0f-1a2b-4c3d-8e4f-5a6b7c8d9e0f",
  "number": 12,
  "name": "Close the parent when its subtasks are done",
  "product": "projects",
  "kind": "rule",
  "state": "enabled",
  "trigger": "task_transitioned",
  "owner": {
    "id": "8d0e5f7a-1c2b-4d3e-8f9a-0b1c2d3e4f5a",
    "name": "Priya Shah"
  },
  "scope": {
    "kind": "one",
    "family": null,
    "items": [
      {
        "kind": "project",
        "id": "3d4e5f6a-7b8c-4d9e-8f0a-1b2c3d4e5f6a",
        "key": "WEB",
        "name": "Website"
      }
    ]
  },
  "last_run": {
    "status": "success",
    "at": "2026-12-01T10:15:00.000Z"
  },
  "can_manage": true,
  "updated_at": "2026-11-28T08:00:00.000Z",
  "description": "",
  "notify_on_error": true,
  "edit_access": "managers",
  "triggered_by": "people",
  "actor": {
    "kind": "automation",
    "person": null
  },
  "definition": {
    "version": 1,
    "trigger": {
      "key": "task_transitioned",
      "config": {}
    },
    "steps": []
  },
  "recurring": false,
  "failing_since": null,
  "created_at": "2026-11-20T08:00:00.000Z"
}
```

### Errors

- 400 `invalid`: invalid: A value is wrong or missing, or a parameter is unknown. Every problem is in details.
- 401 `invalid_token`: invalid_token: No token was sent, or it is wrong, expired or revoked, or its person is no longer a member (or is now a guest).
- 403 `insufficient_scope`: insufficient_scope: The token doesn't have the scope this call needs (named in WWW-Authenticate). api_off: The organisation's admins have switched the API off. suspended: projqo has suspended the organisation. refused: The token's person can see the thing but may not do this; the message says why. read_only: The organisation is read-only (over the Free plan's people, or a payment is overdue).
- 404 `not_found`: not_found: Nothing is at this address, or the token's person can't see it: the answer is the same.
- 409 `conflict`: conflict: The thing changed since it was read, or the change clashes with its state.
- 413 `too_large`: too_large: The body or a file is larger than allowed.
- 415 `unsupported_media_type`: unsupported_media_type: The body isn't JSON.
- 429 `rate_limited`: rate_limited: Too many calls in this minute, for the token or for the whole organisation.
- 500 `internal`: internal: Something went wrong on projqo's side (never your mistake).

## List the manual rules you may run on a task

`GET /orgs/{org}/tasks/{task}/manual-rules`

Scope: `automation:read`

The manual rules the task view's automation menu offers you on this task (their groups, task types and scope allow you, and they are on), with the questions each asks, in one page (Jira's Search manual rules for an issue).

### Path parameters

- `org` (string, required): The organisation's id (or its address name). [1 to 100 characters]
- `task` (string, required): The task's id or key (WEB-12). [1 to 60 characters]

### Request

```sh
curl -X GET "https://projqo.example/api/v1/orgs/{org}/tasks/{task}/manual-rules" \
  -H "Authorization: Bearer $PROJQO_TOKEN"
```

### Answer: 200

```json
{
  "items": [
    {
      "id": "7c8d9e0f-1a2b-4c3d-8e4f-5a6b7c8d9e0f",
      "number": 14,
      "name": "Escalate to support",
      "input": [
        {
          "name": "Reason",
          "kind": "text",
          "required": true
        }
      ]
    }
  ],
  "next_cursor": null
}
```

### Errors

- 400 `invalid`: invalid: A value is wrong or missing, or a parameter is unknown. Every problem is in details.
- 401 `invalid_token`: invalid_token: No token was sent, or it is wrong, expired or revoked, or its person is no longer a member (or is now a guest).
- 403 `insufficient_scope`: insufficient_scope: The token doesn't have the scope this call needs (named in WWW-Authenticate). api_off: The organisation's admins have switched the API off. suspended: projqo has suspended the organisation.
- 404 `not_found`: not_found: Nothing is at this address, or the token's person can't see it: the answer is the same.
- 429 `rate_limited`: rate_limited: Too many calls in this minute, for the token or for the whole organisation.
- 500 `internal`: internal: Something went wrong on projqo's side (never your mistake).

## List the manual rules you may run on a page

`GET /orgs/{org}/pages/{page}/manual-rules`

Scope: `automation:read`

The manual Docs rules a page's Page automations dialog offers you, with the questions each asks, in one page.

### Path parameters

- `org` (string, required): The organisation's id (or its address name). [1 to 100 characters]
- `page` (string (uuid), required)

### Request

```sh
curl -X GET "https://projqo.example/api/v1/orgs/{org}/pages/6f1c2a9e-3b7d-4e21-9a55-0c8d2f4b7e10/manual-rules" \
  -H "Authorization: Bearer $PROJQO_TOKEN"
```

### Answer: 200

```json
{
  "items": [
    {
      "id": "7c8d9e0f-1a2b-4c3d-8e4f-5a6b7c8d9e0f",
      "number": 14,
      "name": "Escalate to support",
      "input": [
        {
          "name": "Reason",
          "kind": "text",
          "required": true
        }
      ]
    }
  ],
  "next_cursor": null
}
```

### Errors

- 400 `invalid`: invalid: A value is wrong or missing, or a parameter is unknown. Every problem is in details.
- 401 `invalid_token`: invalid_token: No token was sent, or it is wrong, expired or revoked, or its person is no longer a member (or is now a guest).
- 403 `insufficient_scope`: insufficient_scope: The token doesn't have the scope this call needs (named in WWW-Authenticate). api_off: The organisation's admins have switched the API off. suspended: projqo has suspended the organisation.
- 404 `not_found`: not_found: Nothing is at this address, or the token's person can't see it: the answer is the same.
- 429 `rate_limited`: rate_limited: Too many calls in this minute, for the token or for the whole organisation.
- 500 `internal`: internal: Something went wrong on projqo's side (never your mistake).

## Run a manual rule

`POST /orgs/{org}/automation/rules/{rule}/invocation`

Scope: `automation:write`

Runs a manual rule once on each task (a project rule) or page (a Docs rule) given, as choosing it in the app's automation menu does, with its questions answered in input (Jira's Invoke a manual rule). A target the rule isn't offered to you on (you can't open it, the rule is off, out of scope or not for you) answers invalid_target and runs nothing there, as Jira's INVALID_TARGET_OBJECT; a rule you can neither read nor run on any target given is not found (404). Each run is queued (queued) and done by the automation worker in moments. Up to 100 targets; counts one call per 10.

### Path parameters

- `org` (string, required): The organisation's id (or its address name). [1 to 100 characters]
- `rule` (string, required): The rule's id, or its number (as the app shows it: Rule 12). [1 to 40 characters]

### Headers

- `Idempotency-Key` (string): A unique key (such as a uuid): the same key and body within 24 hours gets the first answer again without a second create; another body gets 422. [1 to 200 characters]

### Body

- `tasks` (array of string): Tasks to run it on: ids or keys. [at most 100 items]
- `pages` (array of string (uuid)): Pages to run it on: ids. [at most 100 items]
- `input` (object): The answers to the rule's questions, by question name: text, a number, a date (YYYY-MM-DD), one of a choice's options, or a person's id.

### Request

```sh
curl -X POST "https://projqo.example/api/v1/orgs/{org}/automation/rules/{rule}/invocation" \
  -H "Authorization: Bearer $PROJQO_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
  "tasks": [
    "string"
  ],
  "pages": [
    "6f1c2a9e-3b7d-4e21-9a55-0c8d2f4b7e10"
  ],
  "input": {}
}'
```

### Answer: 200

```json
{
  "results": [
    {
      "kind": "task",
      "ref": "WEB-14",
      "status": "queued",
      "event_id": "48213"
    },
    {
      "kind": "task",
      "ref": "WEB-15",
      "status": "invalid_target",
      "event_id": null
    }
  ]
}
```

### Errors

- 400 `invalid`: invalid: A value is wrong or missing, or a parameter is unknown. Every problem is in details.
- 401 `invalid_token`: invalid_token: No token was sent, or it is wrong, expired or revoked, or its person is no longer a member (or is now a guest).
- 403 `insufficient_scope`: insufficient_scope: The token doesn't have the scope this call needs (named in WWW-Authenticate). api_off: The organisation's admins have switched the API off. suspended: projqo has suspended the organisation. read_only: The organisation is read-only (over the Free plan's people, or a payment is overdue).
- 404 `not_found`: not_found: Nothing is at this address, or the token's person can't see it: the answer is the same.
- 413 `too_large`: too_large: The body or a file is larger than allowed.
- 415 `unsupported_media_type`: unsupported_media_type: The body isn't JSON.
- 422 `idempotency_key_reused`: idempotency_key_reused: The same Idempotency-Key was sent within 24 hours with a different body.
- 429 `rate_limited`: rate_limited: Too many calls in this minute, for the token or for the whole organisation.
- 500 `internal`: internal: Something went wrong on projqo's side (never your mistake).
