Home / Docs / Collections

Collections API

A collection is a named set of documents: invoices, contracts, support tickets, a codebase. Each is searched on its own.

Create a collection

POST /api/collections with a name: 1 to 64 characters of a-z, 0-9, - and _. Answers 201 with the new collection's id, or 409 if you already have one with that name.

Shell
curl -X POST https://stackgrep.com/api/collections \
  -H "Authorization: Bearer $STACKGREP_KEY" -d '{"name": "contracts"}'
# 201 {"id": 18}

List your collections

GET /api/collections lists every collection with what was written to it and what it takes in storage now. Free.

Shell
curl https://stackgrep.com/api/collections -H "Authorization: Bearer $STACKGREP_KEY"
Response
[{"name": "contracts", "docs_written": 48210, "bytes_written": 391204477,
  "stored_bytes": 201338112, "created_at": "2026-10-04T12:01:33Z"}]
NameTypeWhat it does
namestringThe collection's name, used in every other URL.
docs_writtenintegerDocuments written to it, counting every update.
bytes_writtenintegerBytes of text written to it.
stored_bytesintegerWhat it takes in storage now: the text and its index, old versions included until they're compacted away.
created_atstringWhen it was made (RFC 3339).

Delete a collection

DELETE /api/collections/{name} answers 204. The collection is gone at once; its stored documents are deleted in the background.

Shell
curl -X DELETE https://stackgrep.com/api/collections/contracts \
  -H "Authorization: Bearer $STACKGREP_KEY"
# 204

Next: put documents in it, or feed it from an S3 bucket.

Try it on your own documentsExact and regex search for your agents, from one API. Or see the engine on npm's source first.