Data Access
Overview
The Monospace API structure, endpoints, and response format.
Access the API
Every Monospace workspace exposes a REST API for reading and writing data. The base URL follows this pattern:
https://{your-instance}/api/{workspace}/items/{collection}
Fetch all articles from the blog workspace:
import { createClient } from './generated/monospace';
const client = createClient({
url: 'https://example.monospace.io',
workspace: 'blog',
apiKey: 'YOUR_API_KEY',
});
const articles = await client.Articles.readMany({
fields: ['*'],
});
curl "https://example.monospace.io/api/blog/items/Articles?fields=*" \
-H "Authorization: Bearer YOUR_API_KEY"
const response = await fetch('https://example.monospace.io/api/blog/items/Articles?fields=*', {
headers: {
Authorization: 'Bearer YOUR_API_KEY',
},
});
const { data } = await response.json();
Understand the URL Structure
Each segment of the URL targets a specific resource.
| Segment | Example | Description |
|---|---|---|
| Instance URL | https://example.monospace.io | Your Monospace deployment |
| API path | /api | Fixed prefix for all API requests |
| Workspace slug | /blog | Identifies which workspace to query |
| Items path | /items | Fixed prefix for collection data |
| Collection | /articles | The collection you are accessing |
| Item ID | /7 | Optional — targets a single item |
The table below maps each CRUD operation to its HTTP method and URL pattern.
| Operation | Method | URL Pattern | Description |
|---|---|---|---|
| List items | GET | /api/{workspace}/items/{collection} | Retrieve all items in a collection |
| Get single item | GET | /api/{workspace}/items/{collection}/{id} | Retrieve one item by its primary key |
| Create items | POST | /api/{workspace}/items/{collection} | Create one or more items |
| Update single item | PATCH | /api/{workspace}/items/{collection}/{id} | Update an existing item by ID |
| Update many items | PATCH | /api/{workspace}/items/{collection} | Update items matching a filter |
| Delete single item | DELETE | /api/{workspace}/items/{collection}/{id} | Remove an item by ID |
| Delete many items | DELETE | /api/{workspace}/items/{collection} | Remove items matching a filter |
Read the Response Format
All responses are wrapped in a { data } envelope. List endpoints return an array inside data:
response.json
{
"data": [
{ "id": 1, "title": "Getting Started with Monospace", "author": "alice" },
{ "id": 2, "title": "Data Modeling Best Practices", "author": "bob" }
]
}
List responses gain a sibling meta object when the request asks for one — see Get the Total Count.
Single-item endpoints return an object inside data:
response.json
{
"data": {
"id": 1,
"title": "Getting Started with Monospace",
"author": "alice"
}
}
SDK
The SDK unwraps the
{ data } envelope automatically. See Client Setup for details. SDK
The SDK provides typed methods for every REST endpoint documented here. See the Client SDK Reference for method signatures, type inference, and setup.