{
  "openapi": "3.1.0",
  "info": {
    "title": "Perla (Extraordinaire Work): assistant API",
    "version": "0.3.0",
    "description": "For a person's own AI assistant. Assistants that speak MCP connect at https://work.extraordinaire.ai/mcp and sign in with OAuth 2.1 (metadata: https://work.extraordinaire.ai/.well-known/oauth-protected-resource/mcp). This REST API takes a personal key, which a person creates at https://work.extraordinaire.ai/#/connect. An assistant can start a request, add context, ask for a proposed plan and read status and results. It can never approve, pay or accept: those stay with a person, on the web. Limits per credential: 60 reads and 10 changes a minute. Versioning: the version is in the path; a breaking change goes to a new version; a call to be retired answers with Deprecation and Sunset headers at least 90 days before it stops (policy: https://work.extraordinaire.ai/developers/versioning).",
    "x-deprecation-policy": "https://work.extraordinaire.ai/developers/versioning"
  },
  "servers": [
    {
      "url": "https://work.extraordinaire.ai/api/v1"
    }
  ],
  "security": [
    {
      "bearer": []
    }
  ],
  "externalDocs": {
    "url": "https://work.extraordinaire.ai/llms.txt"
  },
  "paths": {
    "/requests": {
      "post": {
        "operationId": "request_help",
        "summary": "Ask for expert help",
        "description": "Creates a request. Nothing is organised or spent until a person approves at approval_url. A request is long-running work: send `Prefer: respond-async` to get 202 Accepted with its status address (Location, status_url), then poll get_status.",
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "The same value on a retry creates no second request."
          },
          {
            "name": "Prefer",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "respond-async"
              ]
            },
            "description": "respond-async: answer 202 Accepted with the status address to poll."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "text"
                ],
                "properties": {
                  "text": {
                    "type": "string",
                    "minLength": 12
                  },
                  "title": {
                    "type": "string"
                  },
                  "context": {
                    "type": "object",
                    "description": "Permitted technical context. Never credentials or personal data.",
                    "additionalProperties": {
                      "type": "string"
                    }
                  },
                  "dry_run": {
                    "type": "boolean",
                    "description": "true: save nothing; return what would be created and asked."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The request_id, the open questions, approval_url and next_step.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "202": {
            "description": "Accepted (with Prefer: respond-async): the request exists and is being worked on. Poll status_url (also in Location) with get_status.",
            "headers": {
              "Location": {
                "schema": {
                  "type": "string",
                  "format": "uri"
                },
                "description": "The request’s status address."
              },
              "Retry-After": {
                "schema": {
                  "type": "integer"
                },
                "description": "Seconds before the first poll."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "request_id",
                    "status_url"
                  ],
                  "properties": {
                    "request_id": {
                      "type": "string"
                    },
                    "status": {
                      "type": "string"
                    },
                    "status_url": {
                      "type": "string",
                      "format": "uri"
                    },
                    "approval_url": {
                      "type": "string"
                    },
                    "next_step": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/Error"
          }
        }
      },
      "get": {
        "operationId": "list_requests",
        "summary": "List requests",
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 50
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "next_cursor from the previous page."
          }
        ],
        "responses": {
          "200": {
            "description": "requests and next_cursor.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/sandbox/requests": {
      "post": {
        "operationId": "preview_request",
        "summary": "Sandbox: preview a request without a key",
        "description": "No key, no account, nothing saved: what a request with this text would become (title, kind, what was understood, the questions Perla would ask), read with the fixed rules only, and the link a person opens to send it.",
        "security": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "text"
                ],
                "properties": {
                  "text": {
                    "type": "string",
                    "minLength": 12,
                    "maxLength": 6000
                  },
                  "title": {
                    "type": "string"
                  },
                  "lang": {
                    "type": "string",
                    "enum": [
                      "en",
                      "fr",
                      "nl",
                      "es"
                    ]
                  },
                  "context": {
                    "type": "object",
                    "description": "Permitted technical context. Never credentials or personal data.",
                    "additionalProperties": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The preview (sandbox: true, saved: false), request_link and next_step.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "sandbox",
                    "saved",
                    "would_create"
                  ],
                  "properties": {
                    "sandbox": {
                      "type": "boolean"
                    },
                    "saved": {
                      "type": "boolean"
                    },
                    "would_create": {
                      "type": "object"
                    },
                    "request_link": {
                      "type": "string"
                    },
                    "next_step": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/requests/{id}": {
      "get": {
        "operationId": "get_status",
        "summary": "Status of one request",
        "description": "Includes open_questions, the proposed plan and route, whether a person’s approval is still needed, and next_step { who, action, url }.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The request_id."
          }
        ],
        "responses": {
          "200": {
            "description": "The status.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/requests/{id}/context": {
      "post": {
        "operationId": "attach_context",
        "summary": "Attach permitted context",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The request_id."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "context": {
                    "type": "object",
                    "description": "Permitted technical context. Never credentials or personal data.",
                    "additionalProperties": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The context fields now held.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/requests/{id}/proposal": {
      "post": {
        "operationId": "propose_scope",
        "summary": "Ask for one proposed plan",
        "description": "A proposal only. A person approves it at approval_url.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The request_id."
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "prefer": {
                    "type": "string",
                    "enum": [
                      "own_tools",
                      "software",
                      "hybrid",
                      "expert"
                    ]
                  },
                  "avoid": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    },
                    "maxItems": 30
                  },
                  "non_affiliated": {
                    "type": "boolean"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The status, with the proposal.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/requests/{id}/approval": {
      "post": {
        "operationId": "approval",
        "summary": "Always refused",
        "description": "Approval belongs to a person. This call answers 403 with approval_url, the page where they approve.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The request_id."
          }
        ],
        "responses": {
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/requests/{id}/result": {
      "get": {
        "operationId": "get_result",
        "summary": "The result a person accepted",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The request_id."
          }
        ],
        "responses": {
          "200": {
            "description": "The versioned result.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearer": {
        "type": "http",
        "scheme": "bearer",
        "description": "A personal token (xoa_…) created by a person at https://work.extraordinaire.ai/#/connect."
      }
    },
    "responses": {
      "Error": {
        "description": "A refusal, with what to do next.",
        "content": {
          "application/json": {
            "schema": {
              "type": "object",
              "required": [
                "error"
              ],
              "properties": {
                "error": {
                  "type": "object",
                  "required": [
                    "code",
                    "message",
                    "next_step"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "next_step": {
                      "type": "string"
                    },
                    "url": {
                      "type": "string"
                    },
                    "retry_after_s": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}
