# Command the reader (/reference/api/reader/command-reader)

```json
[
  {
    "method": "POST",
    "path": "/api/v1/reader/commands",
    "operationId": "commandReader",
    "tags": [
      "Reader"
    ],
    "summary": "Command the reader",
    "x-required-scope": "reader:control",
    "security": [
      {
        "oauth": [
          "reader:control"
        ]
      },
      {
        "sessionCookie": []
      },
      {
        "secureSessionCookie": []
      }
    ],
    "responses": {
      "200": {
        "description": "What the open reader view did with the command.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ReaderCommandResult"
            }
          }
        }
      },
      "403": {
        "description": "DOCUMENT_NOT_SHARED: the user keeps the goto document from connected apps. INSUFFICIENT_SCOPE: play without audio:generate.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "404": {
        "description": "DOCUMENT_NOT_FOUND: goto named a document the user does not have.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "409": {
        "description": "READER_NEEDS_APPROVAL: the user has not chosen whether to share their reader with connected apps. The call asked them in any open OpenReader page and waited up to a minute; ask them to answer there, then try again.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "429": {
        "description": "Compute admission or usage is limited.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        },
        "headers": {
          "Retry-After": {
            "description": "Seconds until retry.",
            "schema": {
              "type": "integer",
              "minimum": 1
            }
          }
        }
      },
      "default": {
        "description": "Request failed. Inspect error.code and error.message.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      }
    },
    "requestBody": {
      "required": true,
      "content": {
        "application/json": {
          "schema": {
            "$ref": "#/components/schemas/ReaderCommand"
          },
          "examples": {
            "goto": {
              "summary": "Go to a page",
              "value": {
                "type": "goto",
                "documentId": "9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08",
                "page": 12
              }
            },
            "pause": {
              "summary": "Pause",
              "value": {
                "type": "pause"
              }
            }
          }
        }
      }
    },
    "description": "Sends the command to the open OpenReader tab. goto also works from the library, opening the book there. play also needs audio:generate, since playing can generate speech. A browser starts audio only after the user has interacted with the page, so play can report needs_user_gesture. With no view open, the outcome is not_open; for goto, webUrl still opens the reader there."
  }
]
```

## Components

```json
{
  "#/components/schemas/Error": {
    "type": "object",
    "properties": {
      "error": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string"
          },
          "message": {
            "type": "string"
          },
          "retryAfterMs": {
            "type": "number",
            "minimum": 0
          }
        },
        "required": [
          "code",
          "message"
        ]
      }
    },
    "required": [
      "error"
    ]
  },
  "#/components/schemas/ReaderCommand": {
    "oneOf": [
      {
        "type": "object",
        "properties": {
          "type": {
            "const": "goto"
          },
          "documentId": {
            "type": "string",
            "pattern": "^[a-f0-9]{64}$",
            "description": "The document to open."
          },
          "at": {
            "type": "string",
            "maxLength": 512,
            "description": "A sentence key from search or the reader."
          },
          "page": {
            "type": "integer",
            "minimum": 1,
            "maximum": 999999,
            "description": "A PDF page, used when at is absent or not in the plan."
          }
        },
        "required": [
          "type",
          "documentId"
        ]
      },
      {
        "type": "object",
        "properties": {
          "type": {
            "type": "string",
            "enum": [
              "play",
              "pause"
            ]
          }
        },
        "required": [
          "type"
        ]
      }
    ]
  },
  "#/components/schemas/ReaderCommandResult": {
    "type": "object",
    "properties": {
      "outcome": {
        "type": "string",
        "enum": [
          "done",
          "sent",
          "needs_user_gesture",
          "not_found",
          "failed",
          "not_open"
        ]
      },
      "webUrl": {
        "type": [
          "string",
          "null"
        ],
        "description": "goto: opens the reader at the target."
      }
    },
    "required": [
      "outcome",
      "webUrl"
    ]
  }
}
```