ScriptGrain Companies API
Company and product context that grounds a draft in real facts.
Company and product context that grounds a draft in real facts.
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-companies-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 Companies 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: Companies
description: Company and product context that grounds a draft in real facts.
paths:
/v1/companies:
get:
operationId: listCompanies
tags:
- Companies
summary: List company profiles
description: 'Company/product context profiles the key can see: the key owner''s own plus those shared with
the key''s organisation, newest first, up to 100. Pass a company''s `id` as `company_id` on
outline and generation requests to ground a piece in it. `pending_facts` are suggestions from
the learning loop that have not been applied; they only join the live profile when accepted
in the app.'
x-credits: free
x-rate-limit: 60 requests a minute per key (global)
x-plans: all plans
responses:
'200':
description: The company profiles.
headers:
X-Request-Id:
$ref: '#/components/headers/X-Request-Id'
content:
application/json:
schema:
type: object
required:
- companies
properties:
companies:
type: array
items:
$ref: '#/components/schemas/Company'
example:
companies:
- id: 4e5f6a7b-8c9d-4e0f-a1b2-c3d4e5f6a7b8
name: Acme Ledger
website_url: https://acme.example
summary: Bookkeeping software for freelancers.
audience: UK freelancers and sole traders
key_points:
- Automatic bank feeds
- Quarterly tax estimates
terminology:
preferred:
- invoice
banned:
- synergy
source: website
organisation_id: null
pending_facts: []
fact_provenance:
automatic bank feeds:
source: crawl
learned_at: '2026-10-01T10:00:00.000Z'
source_url: https://acme.example
last_refresh_diff: null
created_at: '2026-10-01T10:00:00.000Z'
'401':
$ref: '#/components/responses/Unauthorized'
'429':
$ref: '#/components/responses/RateLimited'
'500':
description: '`internal_error`: the companies query failed.'
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
post:
operationId: createCompany
tags:
- Companies
summary: Create a company profile
description: 'Creates a company profile in one of three ways, chosen by which field is present, checked in
this order: `url` (a website import), `text` (a freeform description) or `name` (manual
fields). A non-empty `url` wins over `text`, and `text` over `name`. The website import reads
up to about ten grounding pages, keeps only claims the pages make, and reports them in
`pages_read`; it needs a paid plan. The description mode needs at least 15 words and uses at
most the first 15,000 characters. The profile is saved to the key owner''s own account.'
x-credits: free
x-rate-limit: 60 requests a minute per key (global)
x-plans: '`url` import: paid plans. `text` and manual creation: all plans.'
requestBody:
required: true
content:
application/json:
schema:
oneOf:
- $ref: '#/components/schemas/CompanyFromUrl'
- $ref: '#/components/schemas/CompanyFromText'
- $ref: '#/components/schemas/CompanyManual'
examples:
url:
summary: Import from a website (paid plans)
value:
url: https://acme.example
text:
summary: Describe it in your own words
value:
text: Acme Ledger is bookkeeping software for UK freelancers. It pulls in bank feeds and estimates your quarterly tax…
manual:
summary: Fill the fields yourself
value:
name: Acme Ledger
summary: Bookkeeping software for freelancers.
audience: UK freelancers and sole traders
key_points:
- Automatic bank feeds
- Quarterly tax estimates
responses:
'200':
description: The new company. `pages_read` is present only for a website import.
headers:
X-Request-Id:
$ref: '#/components/headers/X-Request-Id'
content:
application/json:
schema:
type: object
required:
- company
properties:
company:
$ref: '#/components/schemas/Company'
pages_read:
type: array
description: The pages read for a website import (`url` mode only). Elements are `{url, title}`.
items:
type: object
required:
- url
- title
properties:
url:
type: string
title:
type: string
example:
company:
id: 4e5f6a7b-8c9d-4e0f-a1b2-c3d4e5f6a7b8
name: Acme Ledger
website_url: https://acme.example
summary: Bookkeeping software for freelancers.
audience: UK freelancers and sole traders
key_points:
- Automatic bank feeds
- Quarterly tax estimates
terminology: {}
source: website
organisation_id: null
pending_facts: []
fact_provenance: {}
last_refresh_diff: null
created_at: '2026-10-21T11:20:00.000Z'
pages_read:
- url: https://acme.example
title: Acme Ledger
'400':
description: '`invalid_json`: body is not valid JSON. `invalid_request`: body is not an object, `url` is not an http(s) URL, or none of `url`, `text` or a valid `name` (1 to 120 characters) was given.'
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'401':
$ref: '#/components/responses/Unauthorized'
'403':
description: '`plan_required`: importing from a website needs a paid plan; create the company from `text` or manually instead.'
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'422':
description: '`import_failed`: the site could not be read (`url` mode), or the description was too short or could not be read (`text` mode); the message says which.'
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'429':
$ref: '#/components/responses/RateLimited'
'500':
description: '`internal_error`: the import is not configured, or saving the company 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:
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
CompanyFromUrl:
type: object
title: Import from a website
required:
- url
properties:
url:
type: string
format: uri
pattern: ^https?://
description: The company's website. Paid plans only.
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.
Company:
type: object
required:
- id
- name
- key_points
- terminology
- source
- created_at
properties:
id:
$ref: '#/components/schemas/Uuid'
name:
type: string
website_url:
type:
- string
- 'null'
summary:
type:
- string
- 'null'
audience:
type:
- string
- 'null'
key_points:
type: array
items:
type: string
terminology:
type: object
properties:
preferred:
type: array
items:
type: string
banned:
type: array
items:
type: string
source:
type: string
description: '`website` for a URL import; `manual` for a description or manual fields. Rows made in the app may carry other values (not fixed in code).'
organisation_id:
oneOf:
- $ref: '#/components/schemas/Uuid'
- type: 'null'
description: Set when the company is shared with an organisation in the app; always null for companies created through this endpoint.
pending_facts:
type: array
description: Learning-loop suggestions not yet applied.
items:
type: object
properties:
kind:
type: string
enum:
- fact
- preferred_term
- banned_term
text:
type: string
source:
type: string
enum:
- edit
- crawl
learned_at:
type: string
format: date-time
fact_provenance:
type: object
description: Where each key point came from, keyed by the lowercased fact text.
additionalProperties:
type: object
properties:
source:
type: string
enum:
- crawl
- edit
- described
- manual
learned_at:
type: string
format: date-time
source_url:
type: string
last_refresh_diff:
type:
- object
- 'null'
description: What the most recent website re-crawl changed or proposed. Null if never re-crawled.
properties:
refreshed_at:
type: string
format: date-time
pages_read:
type: integer
added_facts:
type: array
items:
type: string
summary_changed:
type: boolean
audience_changed:
type: boolean
proposed_facts:
type: array
items:
type: string
proposed_summary:
type:
- string
- 'null'
proposed_audience:
type:
- string
- 'null'
created_at:
type: string
format: date-time
CompanyManual:
type: object
title: Manual fields
required:
- name
properties:
name:
type: string
minLength: 1
maxLength: 120
website_url:
type: string
maxLength: 500
description: Longer values are cut to 500 characters.
summary:
type: string
maxLength: 2000
description: Longer values are cut to 2,000 characters.
audience:
type: string
maxLength: 1000
description: Longer values are cut to 1,000 characters.
key_points:
type: array
maxItems: 25
description: Non-string items are dropped; each string is cut to 300 characters; only the first 25 are kept.
items:
type: string
maxLength: 300
CompanyFromText:
type: object
title: Describe it in your own words
required:
- text
properties:
text:
type: string
description: A pitch, rough notes or an About page. At least 15 words; only the first 15,000 characters are used. Ignored if `url` is also sent.
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