Docs
POST /draft_from_sources
https://heyeveryone.ai/api/v1/draft_from_sources
Operation
{
"post": {
"description": "Write a content item's original draft from its sources (fetched links, notes, transcripts and media transcripts added with add_source), in the workspace's voice: one channel-neutral post to adapt later (adapt_content). If the item already has a draft, the new one keeps its topic. Returns the text only; it saves nothing: write it with update_original, or suggest it with propose_edit. Fails with `insufficient_source` (nothing charged) when no source has text yet.\n\nUses heyeveryone AI and costs 2 credits (2 credits per draft). Tell the person before calling it.",
"operationId": "draft_from_sources",
"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"
},
"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"
},
"instructions": {
"maxLength": 2000,
"type": "string"
},
"targetChars": {
"maximum": 5000,
"minimum": 100,
"type": "integer"
},
"idempotencyKey": {
"maxLength": 200,
"minLength": 1,
"type": "string"
}
},
"required": [
"workspaceId",
"pieceId"
],
"type": "object"
}
}
},
"required": true
},
"responses": {
"200": {
"content": {
"application/json": {
"schema": {
"additionalProperties": false,
"properties": {
"text": {
"type": "string"
},
"sourcesUsed": {
"maximum": 9007199254740991,
"minimum": 0,
"type": "integer"
}
},
"required": [
"text",
"sourcesUsed"
],
"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: piece_not_found, insufficient_source, ai_generation_failed, insufficient_credits, plan_limit_reached, idempotency_conflict"
},
"429": {
"$ref": "#/components/responses/RateLimited"
},
"500": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
},
"description": "internal_error"
}
},
"summary": "Draft from sources",
"tags": [
"workspace"
],
"x-heyeveryone-kind": "mutation",
"x-heyeveryone-uses-credits": true
}
}Referenced definitions
{
"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
{
"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
[
{
"bearer": []
},
{
"oauth": [
"agent"
]
}
]