# Assisthub REST API

> JSON REST API for repurposing content with AI. Base URL: http://assisthub.xyz/api/v1. OpenAPI: http://assisthub.xyz/openapi/v1.json

## Authentication

Endpoints that call an AI model, and all library endpoints, require an API key sent as `X-API-Key: ak_...` or `Authorization: Bearer ak_...`. Keys are `ak_` followed by 40 characters and are created in Settings > API keys after signing in. Listing and health endpoints need no key.

## Other ways to integrate

- MCP server for AI agents: `http://assisthub.xyz/mcp` (Streamable HTTP, JSON-RPC 2.0). Authenticate with `Authorization: Bearer ak_...`. Tools: repurpose_content, batch_repurpose, run_agent, list_pipelines, run_pipeline, list_templates, use_template, search_library, get_library_item, delete_library_item, list_providers.
- Webhooks: configure in Settings > Webhooks. Events content.created, content.updated, content.deleted are POSTed as JSON with header `X-Assisthub-Signature: t=<unix>,v1=<hex HMAC-SHA256 of "<t>.<body>" using the endpoint secret>`. Guide: http://assisthub.xyz/ApiDocs/Integrations

## Rate limits

- AI endpoints: 20 requests per minute per API key.
- All requests combined: 600 per minute.
- Over the limit the API returns `429` with a `Retry-After` header (seconds) and `{ "error": "...", "retryAfterSeconds": n }`.

## Errors

Errors return a non-2xx status and `{ "error": "message" }`: `400` invalid input or unknown provider, `401` missing or invalid key, `404` unknown pipeline or template, `429` rate limited, `500` provider or server failure (safe to retry).

Valid `provider` values: `Ollama`, `OpenAI`, `Claude`, `Gemini`, `DeepSeek`, `Qwen`, `Auto`. Results of successful AI calls are also saved to the account's library and the response includes `contentId`.

## Content

### Repurpose content

`POST /api/v1/generate` · API key required · counts toward the AI limit

Rewrite a piece of content for another format and tone.

Body (JSON):

- `content` (string, required): The text to repurpose.
- `sourceFormat` (string, optional): What the content is now, e.g. Blog, Article, Podcast. Default: Blog.
- `targetFormat` (string, optional): What to turn it into, e.g. Twitter, LinkedIn, Email. Default: Twitter.
- `tone` (string, optional): Professional, Casual, Humorous, Educational or Inspirational. Default: Professional.
- `provider` (string, optional): AI provider for this call. Default: the workspace default.

Example request:

```json
{
  "content": "Artificial intelligence is changing how teams plan, write and publish. The best results come from pairing a clear brief with a model that knows your audience.",
  "sourceFormat": "Blog",
  "targetFormat": "LinkedIn",
  "tone": "Professional"
}
```

Example response:

```json
{
  "success": true,
  "contentId": "3f6c1e2a-…",
  "content": "AI is reshaping how teams plan, write and publish…",
  "provider": "DeepSeek",
  "durationMs": 4180
}
```

### Run an agent

`POST /api/v1/agent/{method}` · API key required · counts toward the AI limit

Run a single-purpose agent such as summarize, seo or hashtags on your content.

Path parameters:

- `method` (string, required): One of the agent methods listed below. Values: summarize, seo, social, email, blog, adcopy, bullets, title, rewrite, hashtags, questions, sentiment, keywords, grammar, faq, quiz, studyguide

Body (JSON):

- `content` (string, required): The text to process.
- `provider` (string, optional): AI provider for this call. Default: the workspace default.

Example request:

```json
{
  "content": "Artificial intelligence is changing how teams plan, write and publish. The best results come from pairing a clear brief with a model that knows your audience."
}
```

Example response:

```json
{
  "success": true,
  "method": "summarize",
  "content": "Pair a clear brief with an audience-aware model to get better AI-assisted content.",
  "durationMs": 2240
}
```

### Repurpose for several channels

`POST /api/v1/batch` · API key required · counts toward the AI limit

Rewrite the same content for up to 8 target formats in one call. Each successful result is saved to the library.

Body (JSON):

- `content` (string, required): The text to repurpose.
- `targetFormats` (string[], required): 1 to 8 formats, e.g. ["LinkedIn", "Twitter", "Email"].
- `sourceFormat` (string, optional): What the content is now. Default: Blog.
- `tone` (string, optional): Default: Professional.
- `provider` (string, optional): AI provider for every format. Default: the workspace default.

Example request:

```json
{
  "content": "Artificial intelligence is changing how teams plan, write and publish. The best results come from pairing a clear brief with a model that knows your audience.",
  "targetFormats": ["LinkedIn", "Twitter", "Email"],
  "tone": "Professional"
}
```

Example response:

```json
{
  "success": true,
  "results": [
    { "targetFormat": "LinkedIn", "success": true, "contentId": "…", "content": "…", "error": null, "durationMs": 4100 },
    { "targetFormat": "Twitter", "success": true, "contentId": "…", "content": "…", "error": null, "durationMs": 3600 }
  ]
}
```

### List agents

`GET /api/v1/agents` · no key needed

List the single-purpose agent methods you can call with Run an agent.

Example response:

```json
{
  "agents": [
    { "method": "summarize", "description": "Concise summary" },
    { "method": "hashtags", "description": "Hashtags" }
  ]
}
```

## Pipelines

### List pipelines

`GET /api/v1/pipelines` · no key needed

List every multi-step pipeline with its id, category and number of steps.

Example response:

```json
{
  "count": 22,
  "pipelines": [
    { "id": "…", "name": "Blog Creation Pipeline", "description": "…", "category": "Content Marketing", "steps": 5 }
  ]
}
```

### Run a pipeline

`POST /api/v1/pipelines/{id}/execute` · API key required · counts toward the AI limit

Run every step of a pipeline on your content. Each step's output feeds the next.

Path parameters:

- `id` (string, required): Pipeline id from List pipelines.

Body (JSON):

- `content` (string, required): The input for the first step.
- `provider` (string, optional): AI provider for every step. Default: the workspace default.

Example request:

```json
{
  "content": "Artificial intelligence is changing how teams plan, write and publish. The best results come from pairing a clear brief with a model that knows your audience."
}
```

Example response:

```json
{
  "success": true,
  "pipelineId": "…",
  "totalDurationMs": 18250,
  "steps": [
    { "name": "Summarize", "success": true, "output": "…", "error": null, "durationMs": 3120 }
  ]
}
```

## Templates

### List templates

`GET /api/v1/templates` · no key needed

List the saved templates you can apply with Use a template.

Example response:

```json
{
  "count": 8,
  "templates": [
    { "id": "…", "name": "Meeting Notes to Email", "category": "Business", "sourceFormat": "Other", "targetFormat": "Email", "tone": "Professional" }
  ]
}
```

### Use a template

`POST /api/v1/templates/{id}/use` · API key required · counts toward the AI limit

Apply a saved template's formats, tone and instructions to your content.

Path parameters:

- `id` (string, required): Template id from List templates.

Body (JSON):

- `content` (string, required): The text to transform.

Example request:

```json
{
  "content": "Artificial intelligence is changing how teams plan, write and publish. The best results come from pairing a clear brief with a model that knows your audience."
}
```

Example response:

```json
{
  "success": true,
  "templateId": "…",
  "templateName": "Meeting Notes to Email",
  "content": "…",
  "durationMs": 3900
}
```

## Library

### Search the library

`GET /api/v1/content` · API key required

List saved content, newest first, with optional search and filters. Returns metadata without the full text.

Query parameters:

- `q` (string, optional): Words to find in titles, text and tags.
- `origin` (string, optional): Only items from one source. Values: Repurpose, Batch, Pipeline, Template, Scheduled, API, Agent, Manual
- `format` (string, optional): Only items for one target format, e.g. LinkedIn.
- `favorite` (boolean, optional): true for favorites only.
- `limit` (integer, optional): 1 to 100. Default: 20.
- `offset` (integer, optional): Items to skip, for paging. Default: 0.

Example response:

```json
{
  "total": 42,
  "offset": 0,
  "limit": 20,
  "items": [
    { "id": "…", "title": "LinkedIn · How we cut onboarding time…", "origin": "API", "sourceFormat": "Blog", "targetFormat": "LinkedIn",
      "tone": "Professional", "provider": "DeepSeek", "tags": ["api/generate"], "isFavorite": false,
      "createdAt": "2026-10-22T09:30:00Z", "url": "/Content/Details/…" }
  ]
}
```

### Get a library item

`GET /api/v1/content/{id}` · API key required

Get one saved item, including the source text (input) and the generated text (output).

Path parameters:

- `id` (string, required): Library item id, from a generation response (contentId) or the search results.

Example response:

```json
{
  "id": "…",
  "title": "LinkedIn · How we cut onboarding time…",
  "origin": "API",
  "targetFormat": "LinkedIn",
  "output": "We cut onboarding time in half. Here's what changed…",
  "input": "How we cut onboarding time in half…",
  "createdAt": "2026-10-22T09:30:00Z",
  "url": "/Content/Details/…"
}
```

### Delete a library item

`DELETE /api/v1/content/{id}` · API key required

Permanently delete one saved item. Fires the content.deleted webhook.

Path parameters:

- `id` (string, required): Library item id.

Example response:

```json
{ "success": true, "id": "…" }
```

## System

### List providers

`GET /api/v1/providers` · no key needed

List the AI providers, whether each is configured, and whether it is reachable now.

Example response:

```json
{
  "defaultProvider": "DeepSeek",
  "providers": [
    { "name": "DeepSeek", "configured": true, "available": true },
    { "name": "Ollama", "configured": true, "available": false }
  ]
}
```

### Health check

`GET /api/v1/health` · no key needed

Service status and provider reachability. Not rate limited.

Example response:

```json
{
  "status": "healthy",
  "timestamp": "2026-10-22T09:30:00Z",
  "version": "1.0.0",
  "defaultProvider": "DeepSeek",
  "providers": { "Ollama": false, "OpenAI": true, "DeepSeek": true }
}
```

