Codehooks Documents API
CRUD operations on NoSQL collection documents
CRUD operations on NoSQL collection documents
openapi: 3.1.0
info:
title: Codehooks Database REST Documents API
description: The Codehooks.io Database REST API provides a complete and secure REST API for basic database CRUD (Create, Read, Update, Delete) operations on NoSQL collections. The API supports querying with MongoDB-like syntax, pagination, sorting, and field selection. It also includes a key-value store for caching and fast lookups, and a queue system for asynchronous job processing. All endpoints are prefixed with the project ID and datastore space name.
version: 1.0.0
contact:
name: Codehooks
url: https://codehooks.io/
license:
name: Proprietary
url: https://codehooks.io/terms
servers:
- url: https://{projectId}.api.codehooks.io/{space}
description: Codehooks API endpoint
variables:
projectId:
default: myproject-ff00
description: The project ID assigned to your Codehooks project
space:
default: dev
description: The datastore space name (e.g. dev, staging, prod)
security:
- apiKey: []
tags:
- name: Documents
description: CRUD operations on NoSQL collection documents
paths:
/{collection}:
get:
operationId: listDocuments
summary: Codehooks List documents in a collection
description: Retrieve documents from a collection with optional query parameters for filtering, sorting, pagination, and field selection. Supports both simple key-value query parameters and advanced NoSQL JSON query syntax via the q parameter.
tags:
- Documents
parameters:
- name: collection
in: path
required: true
description: The name of the collection to query
schema:
type: string
- name: q
in: query
description: Advanced NoSQL JSON query object (URL-encoded). Supports MongoDB-like operators such as $gt, $gte, $lt, $lte, $ne, $in, $nin, $exists, $regex, $or, and $and.
schema:
type: string
- name: h
in: query
description: Query hints as a JSON object (URL-encoded). Supports fields, sort, skip, limit, and projection.
schema:
type: string
- name: limit
in: query
description: Maximum number of documents to return
schema:
type: integer
default: 100
- name: offset
in: query
description: Number of documents to skip in the result set
schema:
type: integer
default: 0
- name: sort
in: query
description: Comma-separated list of fields to sort by. Prefix with - for descending order.
schema:
type: string
- name: fields
in: query
description: Comma-separated list of fields to include in the response
schema:
type: string
responses:
'200':
description: A list of documents matching the query
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/Document'
'401':
description: Unauthorized - invalid or missing API key
'404':
description: Collection not found
post:
operationId: createDocument
summary: Codehooks Create a new document
description: Create a new document in the specified collection. The document will be assigned a unique _id if one is not provided.
tags:
- Documents
parameters:
- name: collection
in: path
required: true
description: The name of the collection to add the document to
schema:
type: string
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/DocumentInput'
responses:
'201':
description: Document created successfully
content:
application/json:
schema:
$ref: '#/components/schemas/Document'
'400':
description: Invalid document data
'401':
description: Unauthorized - invalid or missing API key
/{collection}/{id}:
get:
operationId: getDocument
summary: Codehooks Get a document by ID
description: Retrieve a single document from a collection by its unique identifier.
tags:
- Documents
parameters:
- name: collection
in: path
required: true
description: The name of the collection
schema:
type: string
- name: id
in: path
required: true
description: The unique identifier of the document
schema:
type: string
responses:
'200':
description: The requested document
content:
application/json:
schema:
$ref: '#/components/schemas/Document'
'401':
description: Unauthorized - invalid or missing API key
'404':
description: Document not found
put:
operationId: replaceDocument
summary: Codehooks Replace a document
description: Replace an entire document in the collection by its unique identifier. The entire document is replaced with the provided data.
tags:
- Documents
parameters:
- name: collection
in: path
required: true
description: The name of the collection
schema:
type: string
- name: id
in: path
required: true
description: The unique identifier of the document
schema:
type: string
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/DocumentInput'
responses:
'200':
description: Document replaced successfully
content:
application/json:
schema:
$ref: '#/components/schemas/Document'
'400':
description: Invalid document data
'401':
description: Unauthorized - invalid or missing API key
'404':
description: Document not found
patch:
operationId: updateDocument
summary: Codehooks Update a document
description: Partially update a document in the collection by its unique identifier. Only the provided fields are updated. Supports MongoDB-like update operators such as $set, $inc, $unset, $push, and $pull.
tags:
- Documents
parameters:
- name: collection
in: path
required: true
description: The name of the collection
schema:
type: string
- name: id
in: path
required: true
description: The unique identifier of the document
schema:
type: string
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/DocumentUpdate'
responses:
'200':
description: Document updated successfully
content:
application/json:
schema:
$ref: '#/components/schemas/Document'
'400':
description: Invalid update data
'401':
description: Unauthorized - invalid or missing API key
'404':
description: Document not found
delete:
operationId: deleteDocument
summary: Codehooks Delete a document
description: Delete a single document from a collection by its unique identifier.
tags:
- Documents
parameters:
- name: collection
in: path
required: true
description: The name of the collection
schema:
type: string
- name: id
in: path
required: true
description: The unique identifier of the document
schema:
type: string
responses:
'200':
description: Document deleted successfully
'401':
description: Unauthorized - invalid or missing API key
'404':
description: Document not found
/{collection}/_byquery:
patch:
operationId: updateDocumentsByQuery
summary: Codehooks Update multiple documents by query
description: Update multiple documents in a collection that match the provided query parameters. Supports MongoDB-like update operators such as $set, $inc, $unset, $push, and $pull.
tags:
- Documents
parameters:
- name: collection
in: path
required: true
description: The name of the collection
schema:
type: string
- name: q
in: query
description: NoSQL JSON query object (URL-encoded) to select documents to update.
schema:
type: string
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/DocumentUpdate'
responses:
'200':
description: Documents updated successfully
content:
application/json:
schema:
type: object
properties:
count:
type: integer
description: Number of documents updated
'400':
description: Invalid update data or query
'401':
description: Unauthorized - invalid or missing API key
delete:
operationId: deleteDocumentsByQuery
summary: Codehooks Delete multiple documents by query
description: Delete multiple documents in a collection that match the provided query parameters.
tags:
- Documents
parameters:
- name: collection
in: path
required: true
description: The name of the collection
schema:
type: string
- name: q
in: query
description: NoSQL JSON query object (URL-encoded) to select documents to delete.
schema:
type: string
responses:
'200':
description: Documents deleted successfully
content:
application/json:
schema:
type: object
properties:
count:
type: integer
description: Number of documents deleted
'401':
description: Unauthorized - invalid or missing API key
/{collection}/_count:
get:
operationId: countDocuments
summary: Codehooks Count documents in a collection
description: Return the count of documents in a collection, optionally filtered by a query.
tags:
- Documents
parameters:
- name: collection
in: path
required: true
description: The name of the collection
schema:
type: string
- name: q
in: query
description: Optional NoSQL JSON query object to filter the count
schema:
type: string
responses:
'200':
description: The count of matching documents
content:
application/json:
schema:
type: object
properties:
count:
type: integer
'401':
description: Unauthorized - invalid or missing API key
components:
schemas:
Document:
type: object
properties:
_id:
type: string
description: Unique document identifier
additionalProperties: true
description: A document in a Codehooks collection. Documents are schema-flexible JSON objects with a system-assigned _id.
DocumentInput:
type: object
additionalProperties: true
description: Input data for creating or replacing a document. Any valid JSON object is accepted.
DocumentUpdate:
type: object
additionalProperties: true
description: Partial update data for a document. Supports direct field updates or MongoDB-like update operators such as $set, $inc, $unset, $push, and $pull.
securitySchemes:
apiKey:
type: apiKey
name: x-apikey
in: header
description: API key for authentication. Obtain from the Codehooks.io dashboard or CLI.
bearerAuth:
type: http
scheme: bearer
bearerFormat: JWT
description: JWT token for authentication