# POST /ask_workspace

Source: https://heyeveryone.ai/docs/api/ask_workspace

> https://heyeveryone.ai/api/v1/ask_workspace

## Operation

```json
{
  "post": {
    "description": "Ask heyeveryone's own AI a question about this workspace's content, calendar and results (\"What did best on LinkedIn last month?\"). It reads with the read tools you have, never writes, and answers in plain words with links to what it used; it says so when the data can't answer (leads, sales). Returns `runId` at once: poll list_ai_runs with `runId` until the run ends; its `output` holds `answer`, `citations` and `read`. `followUpOf`: an earlier Ask's runId. Free instead: read get_results and query_content yourself.\n\nUses heyeveryone AI and costs credits: Up to 25 credits a question, usually about 12 and at least 5, charged by what it uses (nothing if it fails or is stopped before answering). Tell the person before calling it.",
    "operationId": "ask_workspace",
    "parameters": [
      {
        "description": "Optional; the same as the body's `idempotencyKey`. The same key from the same agent in the same workspace within 24 hours returns the first result instead of doing it again.",
        "in": "header",
        "name": "Idempotency-Key",
        "required": false,
        "schema": {
          "maxLength": 200,
          "minLength": 1,
          "type": "string"
        }
      }
    ],
    "requestBody": {
      "content": {
        "application/json": {
          "schema": {
            "properties": {
              "workspaceId": {
                "format": "uuid",
                "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$",
                "type": "string"
              },
              "question": {
                "maxLength": 2000,
                "minLength": 1,
                "type": "string"
              },
              "context": {
                "properties": {
                  "pieceId": {
                    "format": "uuid",
                    "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$",
                    "type": "string"
                  },
                  "note": {
                    "maxLength": 300,
                    "minLength": 1,
                    "type": "string"
                  }
                },
                "type": "object"
              },
              "followUpOf": {
                "format": "uuid",
                "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$",
                "type": "string"
              },
              "idempotencyKey": {
                "maxLength": 200,
                "minLength": 1,
                "type": "string"
              }
            },
            "required": [
              "workspaceId",
              "question"
            ],
            "type": "object"
          }
        }
      },
      "required": true
    },
    "responses": {
      "200": {
        "content": {
          "application/json": {
            "schema": {
              "additionalProperties": false,
              "properties": {
                "runId": {
                  "format": "uuid",
                  "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$",
                  "type": "string"
                },
                "status": {
                  "enum": [
                    "queued",
                    "running",
                    "succeeded",
                    "stopped_at_max",
                    "failed",
                    "cancelled"
                  ],
                  "type": "string"
                },
                "answer": {
                  "type": [
                    "string",
                    "null"
                  ]
                },
                "citations": {
                  "items": {
                    "additionalProperties": false,
                    "properties": {
                      "url": {
                        "type": "string"
                      },
                      "label": {
                        "type": "string"
                      },
                      "tool": {
                        "type": [
                          "string",
                          "null"
                        ]
                      }
                    },
                    "required": [
                      "url",
                      "label",
                      "tool"
                    ],
                    "type": "object"
                  },
                  "type": "array"
                },
                "cost": {
                  "additionalProperties": false,
                  "properties": {
                    "estimate": {
                      "additionalProperties": false,
                      "properties": {
                        "min": {
                          "maximum": 9007199254740991,
                          "minimum": 0,
                          "type": "integer"
                        },
                        "max": {
                          "maximum": 9007199254740991,
                          "minimum": 0,
                          "type": "integer"
                        },
                        "typical": {
                          "anyOf": [
                            {
                              "maximum": 9007199254740991,
                              "minimum": 0,
                              "type": "integer"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        }
                      },
                      "required": [
                        "min",
                        "max",
                        "typical"
                      ],
                      "type": "object"
                    },
                    "charged": {
                      "anyOf": [
                        {
                          "maximum": 9007199254740991,
                          "minimum": 0,
                          "type": "integer"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "soFar": {
                      "maximum": 9007199254740991,
                      "minimum": 0,
                      "type": "integer"
                    },
                    "stoppedAtMax": {
                      "type": "boolean"
                    },
                    "continueEstimate": {
                      "anyOf": [
                        {
                          "additionalProperties": false,
                          "properties": {
                            "min": {
                              "maximum": 9007199254740991,
                              "minimum": 0,
                              "type": "integer"
                            },
                            "max": {
                              "maximum": 9007199254740991,
                              "minimum": 0,
                              "type": "integer"
                            }
                          },
                          "required": [
                            "min",
                            "max"
                          ],
                          "type": "object"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  },
                  "required": [
                    "estimate",
                    "charged",
                    "soFar",
                    "stoppedAtMax",
                    "continueEstimate"
                  ],
                  "type": "object"
                },
                "replayed": {
                  "type": "boolean"
                }
              },
              "required": [
                "runId",
                "status",
                "answer",
                "citations",
                "cost",
                "replayed"
              ],
              "type": "object"
            }
          }
        },
        "description": "Success"
      },
      "400": {
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        },
        "description": "invalid_input: the body does not match the schema"
      },
      "401": {
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        },
        "description": "unauthenticated: missing, invalid, expired or revoked token"
      },
      "403": {
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        },
        "description": "forbidden: the agent may not do this (for example, another workspace)"
      },
      "404": {
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        },
        "description": "not_found"
      },
      "409": {
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        },
        "description": "conflict"
      },
      "422": {
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        },
        "description": "Service-specific errors: insufficient_credits, too_many_runs, idempotency_conflict, plan_limit_reached"
      },
      "429": {
        "$ref": "#/components/responses/RateLimited"
      },
      "500": {
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        },
        "description": "internal_error"
      }
    },
    "summary": "Ask heyeveryone",
    "tags": [
      "workspace"
    ],
    "x-heyeveryone-kind": "mutation",
    "x-heyeveryone-uses-credits": true
  }
}
```

## Referenced definitions

```json
{
  "schemas": {
    "Error": {
      "properties": {
        "error": {
          "description": "A stable error code, for example forbidden.",
          "type": "string"
        },
        "message": {
          "description": "What went wrong, in plain words.",
          "type": "string"
        }
      },
      "required": [
        "error",
        "message"
      ],
      "type": "object"
    }
  },
  "responses": {
    "RateLimited": {
      "content": {
        "application/json": {
          "schema": {
            "$ref": "#/components/schemas/Error"
          }
        }
      },
      "description": "rate_limited: too many requests from this agent, account or address (docs/setup/agents.md, Rate limits); wait the Retry-After seconds, then retry",
      "headers": {
        "Retry-After": {
          "description": "Seconds to wait before retrying.",
          "schema": {
            "minimum": 1,
            "type": "integer"
          }
        }
      }
    }
  }
}
```

## Authentication

```json
{
  "bearer": {
    "description": "Personal access token (hey_pat_...)",
    "scheme": "bearer",
    "type": "http"
  },
  "oauth": {
    "flows": {
      "authorizationCode": {
        "authorizationUrl": "https://heyeveryone.ai/oauth/authorize",
        "refreshUrl": "https://heyeveryone.ai/oauth/token",
        "scopes": {
          "agent": "Act as your agent in the workspaces you choose"
        },
        "tokenUrl": "https://heyeveryone.ai/oauth/token"
      }
    },
    "type": "oauth2"
  }
}
```

## Security requirements

```json
[
  {
    "bearer": []
  },
  {
    "oauth": [
      "agent"
    ]
  }
]
```
