ghost_ink

API reference

Everything is JSON over HTTPS at https://ghost-ink.dev/v1, and every request carries a token.

Authentication

Make a token on your account page and send it as a bearer token. Tokens start with gink_, and can be revoked there at any time.

curl https://ghost-ink.dev/v1/account -H "Authorization: Bearer $GHOST_INK_TOKEN"

A copy key

A key names one sale: 32 hexadecimal characters, so 128 random bits. You choose it, or we mint one for you, and you record it against the order. It is what a trace gives back. We recommend the value to have a high entropy. If your copy needs to be re-signed, you can reuse the key to repeat a signing. We recommend generating these at random using a proper random number generator with high entropy.

A book ID names the product, not the copy: one stable string for every copy of an edition. Kind of like an ISBN. Many EPUB authoring tools will set one for you, in which case we will read it and use it. For example, Adobe InDesign adds a UID identifier to your EPUB package, which we will use as your id. You will need to retain this book ID as well, as a pirated copy may have removed it from the book!

Your account uses its own secure secret which is unique to you. You won't be able to analyze copies generated for others. You do not need to retain, store, or transmit that secret anywhere - it is stored securely on our end.

Long-running operations

Signing a book or tracing one takes seconds to minutes (with especially large books/books having lots of assets), so we don't do these inline with your request. POST answers 202 Accepted straight away with the operation, a Location header pointing at it, and Retry-After saying how many seconds to wait before polling that location.

queued→running→succeededorfailed

While it runs, progress holds the percentage and a status line. Poll the url until status is succeeded or failed; finished operations stop sending Retry-After.

Send an Idempotency-Key header with any POST that might be retried. We will not charge you for idempotent request retries.

Errors

Every error has the same shape, with a machine-readable code and a sentence for humans.

{ "error": { "code": "invalid", "message": "Key must be 32 hexadecimal characters",
             "details": { "key": ["must be 32 hexadecimal characters"] } } }
StatusCodeMeans
401unauthorizedNo token, or one that has been revoked.
402insufficient_creditsToo few credits for a signing or an analysis. Nothing was queued.
404not_foundNo such master or operation on this account.
413too_largeA master over 500 MB.
403masters_lockedStoring masters opens with the account's first purchase of credits.
422invalid, not_an_epub, already_signedA parameter is missing or malformed, the file is not an EPUB, or it is a copy ghost_ink has already signed: sign or store the original book.
429rate_limitedToo many requests. Retry-After says how many seconds until you may send the next. See rate limits.

An operation that fails after it was accepted reports status: "failed" with an error object of the same shape, and a failed signing returns its credit.

Rate limits

Requests that send a book (POST /v1/signings, POST /v1/analyses and POST /v1/masters) share one limit per account. A request past the limit gets 429 with rate_limited, along with a Retry-After header. Please do observe the limits. Send an Idempotency-Key and a retry is safe. GET requests and polling are not limited.

Signings

A signing stamps one copy for one sale. Should it fail, you won't be charged any credits'

POST /v1/signings

Multipart when you send the book with the request; JSON or multipart when you sign from a stored master.

FieldDescription
fileThe EPUB to sign, as multipart. As soon as the copy is made, the original is going to be deleted. Give this or master_id.
master_idThe lqm_ id of a stored master, instead of file.
book_idThe book ID to sign under. With file it defaults to the EPUB's own unique identifier (its ISBN or URN), or to a digest of the book's contents if it has none; with master_id, to the master's. You will need the book ID to do tracing, and it gets returned in book_id and book_id_origin; a trace needs it.
key32 hexadecimal characters naming this sale. Minted for you when absent, and returned either way.
valuesStrings for the master's placeholder spans, as {"buyer_name": "Ada Lovelace"}.
request
curl https://ghost-ink.dev/v1/signings -H "Authorization: Bearer $GHOST_INK_TOKEN" \
  -H "Idempotency-Key: order-1234" \
  -F file=@wonderland.epub \
  -F key=9f2c41d07a6b4e1c8d35f0b2e6a19c47 \
  -F "values[buyer_name]=Ada Lovelace"
202 Accepted · Location: https://ghost-ink.dev/v1/signings/0199e3a1-… · Retry-After: 2
{
  "id": "0199e3a1-5c2e-7b40-9d11-8f0e4a6c2b17",
  "object": "signing",
  "status": "queued",
  "progress": { "percent": 0, "message": null },
  "book_id": "urn:isbn:9780000000000",
  "book_id_origin": "epub",
  "title": "Alice’s Adventures in Wonderland",
  "key": "9f2c41d07a6b4e1c8d35f0b2e6a19c47",
  "master_id": null,
  "deliverable": null,
  "error": null,
  "url": "https://ghost-ink.dev/v1/signings/0199e3a1-…"
}

book_id_origin says where the book ID came from: request when you sent it (or the master was stored with one you sent), epub when it is the EPUB's own identifier, digest when the EPUB has none and it is a SHA-256 of the book's contents. A file that is not an EPUB gets refused with 422 not_an_epub, and a copy ghost_ink has already signed with 422 already_signed, before a credit is taken.

GET /v1/signings/:id

Once succeeded, deliverable.url downloads the signed copy. The URL is signed and lasts an hour; every read of the signing makes a fresh one, so read the signing again rather than storing the link. We keep the signed copy, encrypted, for 48 hours after it is made, then delete it; download it within that time. If you need to recreate a signed copy later, credits will be deducted from your balance.

{
  "status": "succeeded",
  "progress": { "percent": 100, "message": null },
  "copy_label": "pm1.Qz8…",
  "deliverable": {
    "url": "https://ghost-ink.dev/files/blob/…/alices-adventures-in-wonderland-9f2c41d0.epub",
    "url_expires_at": "2026-10-14T10:12:09.000Z",
    "filename": "alices-adventures-in-wonderland-9f2c41d0.epub",
    "byte_size": 19221405,
    "content_type": "application/epub+zip"
  },
  …
}

The copy_label is also written into the book in plain sight. It reverses to the key with your account's secret alone, and is a convenience: a text edit removes it, the hidden marks stay.

GET /v1/signings

Newest first, paged like masters.

Analyses

An analysis reads a copy you found and tells you which key it carries. It is matched against every key this account has signed the book with; name keys you signed elsewhere in keys. The file is deleted once it has been read. An analysis takes 25 credits when accepted, and gives them back if it fails.

POST /v1/analyses

FieldDescription
filerequiredThe copy, as found. A file that is not an EPUB is refused with 422 not_an_epub.
book_idThe book ID it was signed under. Defaults to the copy's own unique identifier, which works when you signed under the EPUB's identifier. Note that a leaker can change it with a text edit, so send it along when you know it. A copy without one is refused with 422 invalid.
keys[]More keys to match against, such as those of signings whose records were deleted.
request
curl https://ghost-ink.dev/v1/analyses -H "Authorization: Bearer $GHOST_INK_TOKEN" \
  -F file=@found-online.epub -F book_id=urn:isbn:9780000000000
GET https://ghost-ink.dev/v1/analyses/0199e3b7-… once finished
{
  "id": "0199e3b7-0a4d-7e21-b8c3-5d6f1e2a9b04",
  "object": "analysis",
  "status": "succeeded",
  "result": {
    "attributed": true,
    "confidence": "certain",
    "key": "9f2c41d07a6b4e1c8d35f0b2e6a19c47",
    "signing_id": "0199e3a1-5c2e-7b40-9d11-8f0e4a6c2b17"
  },
  …
}
ConfidenceMeans
certainThe whole key read back, and it matches a signing.
highNearly all of the key read back, and it matches a signing. Safe to attribute.
mediumEnough to point at one key, not enough to attribute.
lowA weak resemblance only.
noneNo key from the ledger is carried. key is null.

attributed is true at high and certain, the levels we would stand behind. Attributed means the copy carries that key, so it names the sale it was signed for; it does not say who leaked it, as a buyer's copy can be stolen. Treat it as a lead to investigate, not as proof. signing_id is set when the key is one of this account's signings. The report says nothing about which files carried what.

Masters

Optional. A master is the finished, unsigned EPUB, stored with us so a signing can name it by id instead of carrying the book. If you would rather your book not stay with us, skip this and send the file with each signing: it is deleted as soon as the copy is made. Stored masters are encrypted at rest, and deleted when you delete them.

To put a buyer's name in the book, give the master placeholder spans, <span data-ghost-ink="buyer_name">Sample</span>, and pass values when you sign. A placeholder left without a value fails the signing rather than ship a copy with the sample in it.

POST /v1/masters

Multipart upload.

FieldDescription
filerequiredThe EPUB, up to 500 MB.
book_idThe book ID copies of this master are signed under. Defaults to the EPUB's own unique identifier (its ISBN or URN), or a digest of its contents if it has none; book_id_origin says which. Set it yourself to keep the same book ID across revisions of a master.
request
curl https://ghost-ink.dev/v1/masters -H "Authorization: Bearer $GHOST_INK_TOKEN" \
  -F file=@wonderland.epub
201 Created
{
  "id": "lqm_7Hq2xNwPZb3kRrT8mYc1VdLp4sGfE9aKjU6tQhB",
  "book_id": "urn:isbn:9780000000000",
  "book_id_origin": "epub",
  "title": "Alice’s Adventures in Wonderland",
  "byte_size": 18398848,
  "created_at": "2026-10-14T09:12:03.114Z",
  "url": "https://ghost-ink.dev/v1/masters/lqm_7Hq2…"
}

GET /v1/masters GET /v1/masters/:id DELETE /v1/masters/:id

Lists are newest first, 25 to a page (limit up to 100); pass the next_before of one page as before to get the next. Deleting a master keeps the copies already signed from it.

Account

GET /v1/account

{ "email": "rights@publisher.example", "credits": 412,
  "price_per_signing": { "amount_cents": 20, "currency": "USD" },
  "credits_per_analysis": 25 }

Events

Everything billable or metered that happens to the account, oldest first and never rewritten. credits is what each event did to the balance: a signing takes one and an analysis takes 25 when requested, and a failure gives them back, so the balance is always the sum.

GET /v1/events?after=:id

Up to 100 events (limit up to 500) after the one you name. Keep next_after and pass it next time to read only what is new.

{
  "events": [
    { "id": "0199e3a1-5c31-…", "name": "signing.requested", "credits": -1,
      "subject": { "type": "signing", "id": "0199e3a1-5c2e-…" },
      "data": { "book_id": "urn:isbn:9780000000000", "price_cents": 20, "currency": "USD" } },
    { "name": "signing.started", "credits": 0, … },
    { "name": "signing.succeeded", "credits": 0, … }
  ],
  "next_after": "0199e3a1-7f02-…",
  "balance": 411
}

The names are credits.granted, signing.requested, .started, .succeeded, .failed, and the same four for analysis.