ScriptGrain Profiles API
Voice profiles, built from a person's or brand's own writing. Each one is the 45-attribute object every other endpoint reads.
Voice profiles, built from a person's or brand's own writing. Each one is the 45-attribute object every other endpoint reads.
Every API here is available over the APIs.io API and to AI agents over MCP.
One button, every client — Claude, Cursor, VS Code and the rest.
https://apis.io/mcp
find_apisBrowse and filter every API in the catalog.get_api_artifactsOne API's artifacts, grouped by type.get_openapiThe primary OpenAPI for this API.find_similar_apisAPIs that look like this one.apis_io_searchSTART HERE — APIs, providers and tags for one query, each with its total.resolveTurn a domain, URL or GitHub org into the provider it belongs to.find_cohortsEvery scored population of providers in the catalog.curl "https://apis.io/api/v1/apis/scriptgrain-com:scriptgrain-com-profiles-api"
curl "https://apis.io/api/v1/apis?limit=25"
Calls without X-API-Key need no key. Calls with it need a paid plan — get a key.
Free tier, no form to fill in. Signing in shares your email address with us — we store it to create your key and to recognise you if you sign in with another provider. By signing up you are subscribing to the APIs.io and API Evangelist newsletters — you can unsubscribe from any issue. See our Privacy Policy and Terms.
A second provider on the same verified email joins the account you already have.
openapi: 3.2.0
info:
title: ScriptGrain Profiles API
version: 1.0.0
summary: Voice profiles, drafts in a measured voice, and scores for any text, over HTTPS with an API key.
description: 'ScriptGrain measures how a person or brand writes (45 stylometric attributes in eight groups),
drafts new text in that voice, and scores any text against it. This file describes the public
REST API, version 1, as the code serves it. It is generated from `public/openapi.yaml` in the
ScriptGrain repository and checked against the API''s router in CI, so every route listed here
exists and every error code a handler can return is named below. Human documentation: . The same capabilities are exposed
as an MCP server at `https://mcp.scriptgrain.com/mcp` (). ## Authentication
Every request carries an API key: `Authorization: Bearer sg_live_`. Keys are minted in
the app under Settings, then API, and shown once. A key belongs to an organisation. A personal
workspace key acts as its owner and sees the owner''s personal-workspace rows. A team key acts as
the owner or admin who created it, sees only the team''s rows, puts what it creates in the team,
and stops working (`401 invalid_api_key`) once its creator is no longer a team owner or admin;
leaving or being removed from the team revokes the member''s keys for that team. API access is
open on every plan, including Free; a deployment can narrow it (`system_config`
`api_v1.allowed_plans`), in which case non-billing routes answer `403 plan_not_eligible`. Billing routes (`/v1/billing*`) are never plan-gated. Before any route runs, authentication can also answer `401 unauthorized` (header missing or
malformed), `401 invalid_api_key` (unknown or revoked key), `403 organisation_missing` (the
key''s organisation was deleted) or `402 no_subscription` (no billing record resolves). A
deployment missing its secrets answers `500 misconfigured`. These five are not repeated on each
operation below. ## Responses
Successes return the resource directly. Errors return one envelope:
```json
{ "error": { "code": "invalid_request", "message": "brief (string) is required." } }
```
Some errors add fields beside `message` (for example `credits_required` and
`credits_available` on `402 out_of_credits`, `profile_id` on a profile-creation refusal). Every response, success or error, carries an `X-Request-Id` header to quote at support. Invalid JSON in any request body is `400 invalid_json`. A path whose id segment is not a UUID
never reaches a handler: it is `404 not_found`. CORS: the preflight allows `GET`, `POST`, `DELETE` and `OPTIONS` with the `authorization`,
`content-type`, `accept` and `idempotency-key` headers, so every route can be called from a
browser page as well as from servers and tools. ## Rate limits
60 requests a minute per API key on every route (`429 rate_limited`). Some routes add an hourly
budget per account, stated on the operation (`x-rate-limit`): voice-match 200 an hour, profile
extraction 5 an hour, brand mimic 3 an hour, saved edits 200 an hour, invoice 30, portal link 20,
checkout link 10. Polling a job counts against the 60 a minute. ## Credits
Drafts, polish, humanize, page rewrites and brand mimic cost credits from the same pool the app
uses; everything else is free (`x-credits` on each operation). A draft, polish or humanize is
priced by length: up to 5,000 words 1 credit, up to 10,000 words 2, up to 15,000 words 3,
charged per produced variant **after** it is delivered, so a failed call costs nothing. A page
rewrite is 1 credit per 1,500 rewritable words (minimum 1). Brand mimic costs one brand-mimic
credit. A wallet short of the price answers `402 out_of_credits` (or `402 insufficient_credits`
on a page rewrite). Every route that calls a model can also answer `402 budget_exceeded` when the
account''s monthly AI-spend ceiling is reached. ## Long drafts and background jobs
A draft above 4,000 words, or a polish or humanize above 3,000 words, is written in the
background: the call answers `202 Accepted` with a `job` object and a `poll` path. Poll
`GET /v1/jobs/{id}` (or `GET /v1/generations/{id}` for a draft) every 10 to 30 seconds.'
termsOfService: https://scriptgrain.com/terms
contact:
name: ScriptGrain support
email: support@scriptgrain.com
url: https://scriptgrain.com/support
license:
name: ScriptGrain Terms of Service
url: https://scriptgrain.com/terms
servers:
- url: https://auth.scriptgrain.com/functions/v1/api-v1
description: Production. Every path below is appended to this base.
security:
- ApiKey: []
tags:
- name: Profiles
description: Voice profiles, built from a person's or brand's own writing. Each one is the 45-attribute object every other endpoint reads.
paths:
/v1/profiles:
get:
operationId: listProfiles
tags:
- Profiles
summary: List voice profiles
description: 'The organisation''s shared profiles plus, for a personal workspace key, the owner''s
personal-workspace profiles (a team key sees the team''s profiles only), newest first, up to 100. Profiles archived in the app are left out; fetching an archived profile by
id still works. A guest key sees its session''s one profile.'
x-credits: free
x-rate-limit: 60 requests a minute per key (global)
x-plans: all plans
x-guest-allowed: true
responses:
'200':
description: The accessible profiles.
headers:
X-Request-Id:
$ref: '#/components/headers/X-Request-Id'
content:
application/json:
schema:
type: object
required:
- data
properties:
data:
type: array
items:
$ref: '#/components/schemas/ProfileSummary'
example:
data:
- id: 3f2b9c1e-6a4d-4e8f-9b1a-2c3d4e5f6a7b
name: Marketing Voice
status: complete
confidence_score: 0.83
sample_count: 6
created_at: '2026-04-12T09:14:03.000Z'
'401':
$ref: '#/components/responses/Unauthorized'
'429':
$ref: '#/components/responses/RateLimited'
'500':
description: '`internal_error`: the profile query failed.'
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
post:
operationId: createProfile
tags:
- Profiles
summary: Create a voice profile from writing samples
description: 'Stores the samples, creates the profile and queues the two-pass stylometric extraction. It uses the
same durable queue, caps and rate-limit pool as the in-app upload, so one extraction slot is charged
per accepted run. The call answers immediately with status `processing` (HTTP 200, not 202); poll
`GET /v1/profiles/{id}` until `status` is `complete`.
A sample counts toward extraction only when it has at least 50 words, and at least one sample must.
If the gates reject the request after the profile row was created, the rejection leaves a visible
`failed` profile, and its id is returned in `error.profile_id`. If the profile already has a live
extraction job, the existing job id is returned instead of a new one.
Guest keys may call this route with extra limits: one profile per session, at most 25,000 words in
total, and the body''s `shared` is ignored (guest profiles are always personal).'
x-credits: 1 extraction slot per accepted run (monthly plan cap; the Reader plan has a lifetime cap instead)
x-rate-limit: 5 extractions an hour per user (shared with the in-app upload), on top of 60 requests a minute per key
x-plans: all plans (Free/Reader is limited to its lifetime extraction cap)
x-guest-allowed: true
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/CreateProfileRequest'
example:
name: Marketing Voice
shared: false
english_variant: uk
samples:
- We started the studio because most brand writing sounds like it was written by a committee… (at least 50 words)
- Here is what we learned from the first hundred customers…
responses:
'200':
description: Extraction accepted and queued (or already running for this profile).
headers:
X-Request-Id:
$ref: '#/components/headers/X-Request-Id'
content:
application/json:
schema:
$ref: '#/components/schemas/CreateProfileResponse'
example:
profile_id: 3f2b9c1e-6a4d-4e8f-9b1a-2c3d4e5f6a7b
job_id: 8a1d5e70-2b3c-4f6a-9d8e-0c1b2a3f4e5d
status: processing
poll: GET /v1/profiles/3f2b9c1e-6a4d-4e8f-9b1a-2c3d4e5f6a7b
note: Extraction usually completes in under a minute (the longest take about two). Poll until status is 'complete'.
'400':
description: '`invalid_json`: body is not valid JSON. `invalid_request`: the body failed validation (not a JSON object; `samples` missing, empty, over 20, an item not a non-empty string, an item over 5,000 words, more than 50,000 words in total, or no sample with 50+ words; `name` empty or over 120 characters; `english_variant` not `uk` or `us`), or the extraction gates found no usable samples. Guests also get `invalid_request` above 25,000 total words or 200,000 total characters.'
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'401':
$ref: '#/components/responses/Unauthorized'
'402':
description: '`budget_exceeded`: the owner''s monthly AI-spend ceiling is reached. `error.profile_id` names the `failed` profile the rejection left behind.'
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'403':
description: '`extraction_cap_exceeded`: the plan''s extraction cap is used up (monthly, or lifetime on Reader), or the free-taster device gate refused. `error.profile_id` names the `failed` profile left behind. Guest keys: `guest_profile_limit`: the session already holds a profile or has used its one extraction.'
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'429':
description: '`rate_limited`: more than 5 extractions in the last hour for this user (the rejection message is "Rate limit exceeded. Please try again in a few minutes."), or the global 60 requests a minute per key. `error.profile_id` is present for the hourly case.'
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'500':
description: '`internal_error`: the profile or samples insert failed, or extraction failed to start. `error.profile_id` names the `failed` profile when one was created.'
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'503':
description: '`guest_unavailable`: guest sessions only; the global guest extraction cap is reached.'
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
/v1/profiles/{id}:
get:
operationId: getProfile
tags:
- Profiles
summary: Get a voice profile and its extraction progress
description: 'Returns the profile''s status and detail. While the status is `pending` or `processing`,
`progress_percent` follows the extraction job (5 when queued and never started, 10 to 80 across the
per-sample first pass, 85 in the second pass, 95 while finalising; 0 if no job row exists yet). At
`complete` it is 100 and `narrative` and `attributes` are filled; in every other status those two
are `null`. `failed` profiles add `last_error`, and their `progress_percent` is `null`.
`attributes` is the 45-attribute stylometric object, in eight groups: sentence structure,
vocabulary, punctuation, tone and register, rhetoric, perspective and pronouns, structure and
formatting, and signature phrases and banned terms. Its keys are not enumerated here.
The profile must belong to the key''s organisation or to the key owner''s personal workspace;
archived profiles can still be fetched by id.'
x-credits: free
x-rate-limit: 60 requests a minute per key (global)
x-plans: all plans
x-guest-allowed: true
parameters:
- name: id
in: path
required: true
description: The profile id (the router only matches UUID-shaped ids on non-guest keys).
schema:
$ref: '#/components/schemas/Uuid'
responses:
'200':
description: The profile.
headers:
X-Request-Id:
$ref: '#/components/headers/X-Request-Id'
content:
application/json:
schema:
$ref: '#/components/schemas/ProfileDetail'
examples:
processing:
summary: Extraction running
value:
id: 3f2b9c1e-6a4d-4e8f-9b1a-2c3d4e5f6a7b
name: Marketing Voice
status: processing
progress_percent: 45
confidence_score: null
sample_count: 6
total_word_count: 4210
english_variant: uk
company_id: null
created_at: '2026-10-12T09:14:03.000Z'
narrative: null
attributes: null
complete:
summary: Extraction finished
value:
id: 3f2b9c1e-6a4d-4e8f-9b1a-2c3d4e5f6a7b
name: Marketing Voice
status: complete
progress_percent: 100
confidence_score: 0.83
sample_count: 6
total_word_count: 4210
english_variant: uk
company_id: null
created_at: '2026-10-12T09:14:03.000Z'
narrative: 'Direct and warm, with short declarative sentences… '
attributes:
avg_sentence_length: 14.2
contraction_rate: 0.031
'401':
$ref: '#/components/responses/Unauthorized'
'403':
description: '`profile_not_accessible`: the profile is outside the key''s organisation and the owner''s personal workspace.'
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'404':
description: '`profile_not_found`: no profile with that id.'
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'429':
$ref: '#/components/responses/RateLimited'
'500':
description: '`internal_error`: the profile lookup failed.'
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
components:
responses:
RateLimited:
description: '`rate_limited`: more than 60 requests in a minute on this key, or a route''s hourly budget is used.'
headers:
X-Request-Id:
$ref: '#/components/headers/X-Request-Id'
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
example:
error:
code: rate_limited
message: Rate limit exceeded (60 req/min per API key). Try again shortly.
Unauthorized:
description: '`unauthorized`: the `Authorization` header is missing or malformed. `invalid_api_key`: the key
is not recognised or was revoked. For a guest key also `guest_expired` and `guest_claimed`.
'
headers:
X-Request-Id:
$ref: '#/components/headers/X-Request-Id'
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
example:
error:
code: invalid_api_key
message: API key not recognised.
schemas:
EnglishVariant:
type: string
description: British or American English. Omitted, the profile's stored variant applies.
enum:
- uk
- us
Uuid:
type: string
format: uuid
description: A UUID. Path ids that are not UUID-shaped never match a route (404 `not_found`).
example: 3f2b9c1e-6a4d-4e8f-9b1a-2c3d4e5f6a7b
CreateProfileResponse:
type: object
required:
- profile_id
- job_id
- status
- poll
- note
properties:
profile_id:
$ref: '#/components/schemas/Uuid'
job_id:
$ref: '#/components/schemas/Uuid'
status:
type: string
enum:
- processing
poll:
type: string
description: The request line to poll, for example `GET /v1/profiles/{profile_id}`.
note:
type: string
description: A fixed hint about how long extraction takes.
CreateProfileRequest:
type: object
required:
- samples
properties:
name:
type: string
minLength: 1
maxLength: 120
description: Defaults to "API profile" when omitted. Trimmed before the length check.
samples:
type: array
minItems: 1
maxItems: 20
description: Writing samples. Each at most 5,000 words, 50,000 words in total; at least one must have 50 or more words.
items:
type: string
minLength: 1
shared:
type: boolean
default: false
description: '`true` puts the profile in the organisation''s shared workspace; otherwise it goes in the key owner''s personal workspace. Only the value `true` is honoured. A team key always puts the profile in the team.'
english_variant:
$ref: '#/components/schemas/EnglishVariant'
ProfileSummary:
type: object
description: One row of `GET /v1/profiles`.
required:
- id
- name
- status
- confidence_score
- sample_count
- created_at
properties:
id:
$ref: '#/components/schemas/Uuid'
name:
type:
- string
- 'null'
status:
type: string
enum:
- pending
- processing
- complete
- failed
confidence_score:
type:
- number
- 'null'
minimum: 0
maximum: 1
description: 0 to 1 once extraction is complete; null before.
sample_count:
type:
- integer
- 'null'
created_at:
type: string
format: date-time
Error:
type: object
description: 'The error envelope every failure returns. `error.code` is stable and listed in this
description''s error-code table; `error.message` is for people and may change. Some codes
add fields beside them (`credits_required`, `credits_available`, `profile_id`,
`generation_id`, `retry_after_seconds`). A guest key''s errors also carry `claim_url` and
`expires_at` at the top level.
'
required:
- error
properties:
error:
type: object
required:
- code
- message
properties:
code:
type: string
examples:
- invalid_request
- out_of_credits
- profile_not_found
message:
type: string
additionalProperties: true
additionalProperties: true
example:
error:
code: invalid_request
message: brief (string) is required.
ProfileDetail:
type: object
required:
- id
- name
- status
- progress_percent
- confidence_score
- sample_count
- total_word_count
- english_variant
- company_id
- created_at
- narrative
- attributes
properties:
id:
$ref: '#/components/schemas/Uuid'
name:
type:
- string
- 'null'
status:
type: string
enum:
- pending
- processing
- complete
- failed
progress_percent:
type:
- integer
- 'null'
minimum: 0
maximum: 100
description: Extraction progress while `pending` or `processing` (0 with no job row, otherwise 5 to 95); 100 when `complete`; `null` when `failed`.
confidence_score:
type:
- number
- 'null'
minimum: 0
maximum: 1
sample_count:
type:
- integer
- 'null'
total_word_count:
type:
- integer
- 'null'
english_variant:
oneOf:
- $ref: '#/components/schemas/EnglishVariant'
- type: 'null'
company_id:
description: The voice's default company; drafts with no `company_id` are grounded in it. `null` when it has none.
oneOf:
- $ref: '#/components/schemas/Uuid'
- type: 'null'
created_at:
type: string
format: date-time
narrative:
type:
- string
- 'null'
description: The voice narrative. Filled only when `status` is `complete`.
attributes:
type:
- object
- 'null'
additionalProperties: true
description: The 45 measured voice attributes in eight groups (sentence structure, vocabulary, punctuation, tone and register, rhetoric, perspective and pronouns, structure and formatting, signature phrases and banned terms). Filled only when `status` is `complete`.
last_error:
type:
- string
- 'null'
description: Present only when `status` is `failed`.
headers:
X-Request-Id:
description: A 16-character hex id for this request. Quote it when contacting support.
schema:
type: string
pattern: ^[0-9a-f]{16}$
example: 8c99d4ada706a856
securitySchemes:
ApiKey:
type: http
scheme: bearer
bearerFormat: sg_live_<secret> or sg_guest_<token>
description: 'An API key minted in the app (Settings, then API), sent as `Authorization: Bearer sg_live_…`.
The secret is shown once; the server stores a SHA-256 hash. A guest token from
`POST /v1/guest` (`sg_guest_…`) is sent the same way and may call only the routes marked
`x-guest-allowed`.
'
externalDocs:
description: Human-readable API documentation
url: https://scriptgrain.com/docs/api.md