REST API Quickstart
Make your first API request, see data come back, and learn the core operations you will use every day. This guide uses curl and fetch — no SDK or dependencies required.
Get Your API Key
In the Studio, go to Account Settings > Access and create a new API key. Copy the key — you will use it in the Authorization header for every request.
Set it as an environment variable so the examples below work as-is:
export MONOSPACE_API_KEY="your-api-key-here"
All API requests follow this URL pattern:
https://{your-instance}/api/{project}/items/{collection}
This guide assumes you have a project named blog with an articles collection that has id, title, status, and content fields.
Read Your Data
Fetch all articles from your collection:
curl "https://example.monospace.io/api/blog/items/articles?fields=id,title,status" \
-H "Authorization: Bearer $MONOSPACE_API_KEY"
const response = await fetch(
'https://example.monospace.io/api/blog/items/articles?fields=id,title,status',
{
headers: {
Authorization: `Bearer ${process.env.MONOSPACE_API_KEY}`,
},
},
);
const { data } = await response.json();
Every response wraps the result in a { data } envelope. You should see something like:
{
"data": [
{ "id": 1, "title": "Hello World", "status": "published" },
{ "id": 2, "title": "Draft Post", "status": "draft" }
]
}
That's it — your data is live and accessible over HTTP.
limit and offset query parameters to paginate.Create an Item
Send a POST request with a JSON array body. The API always expects an array, even for a single item:
curl -X POST "https://example.monospace.io/api/blog/items/articles?fields=id,title,status" \
-H "Authorization: Bearer $MONOSPACE_API_KEY" \
-H "Content-Type: application/json" \
-d '[{ "title": "My New Article", "status": "draft" }]'
const response = await fetch(
'https://example.monospace.io/api/blog/items/articles?fields=id,title,status',
{
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.MONOSPACE_API_KEY}`,
'Content-Type': 'application/json',
},
body: JSON.stringify([
{ title: 'My New Article', status: 'draft' },
]),
},
);
const { data } = await response.json();
Response:
{
"data": [
{ "id": 3, "title": "My New Article", "status": "draft" }
]
}
The fields query parameter controls which fields are returned in the response — it does not affect what gets written. All fields in the body are always persisted.
Filter and Sort
Add query parameters to narrow and order your results. Filters use bracket notation:
curl -g "https://example.monospace.io/api/blog/items/articles?fields=id,title,status&filter[status][_eq]=published&sort[][title][direction]=asc&limit=10" \
-H "Authorization: Bearer $MONOSPACE_API_KEY"
const params = new URLSearchParams({
fields: 'id,title,status',
'filter[status][_eq]': 'published',
'sort[0][title][direction]': 'asc',
limit: '10',
});
const response = await fetch(
`https://example.monospace.io/api/blog/items/articles?${params}`,
{
headers: {
Authorization: `Bearer ${process.env.MONOSPACE_API_KEY}`,
},
},
);
const { data } = await response.json();
Common filter operators:
| Operator | Description | Example |
|---|---|---|
_eq | Equals | filter[status][_eq]=published |
_neq | Not equals | filter[status][_neq]=archived |
_contains | Contains substring | filter[title][_contains]=API |
_gt, _lt | Greater/less than | filter[views][_gt]=100 |
_in | Matches any value in list | filter[status][_in][0]=draft&filter[status][_in][1]=published |
Sort uses direction with asc or desc:
sort[0][created_at][direction]=desc
-field prefix syntax (e.g. sort=-title) is not supported. Always use the direction object syntax.Update and Delete
Update an Item
Send a PATCH request with only the fields you want to change. Append the item ID to the URL:
curl -X PATCH "https://example.monospace.io/api/blog/items/articles/3?fields=id,title,status" \
-H "Authorization: Bearer $MONOSPACE_API_KEY" \
-H "Content-Type: application/json" \
-d '{ "status": "published" }'
const response = await fetch(
'https://example.monospace.io/api/blog/items/articles/3?fields=id,title,status',
{
method: 'PATCH',
headers: {
Authorization: `Bearer ${process.env.MONOSPACE_API_KEY}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({ status: 'published' }),
},
);
const { data } = await response.json();
Delete an Item
Send a DELETE request with the item ID. Returns no content on success:
curl -X DELETE "https://example.monospace.io/api/blog/items/articles/3" \
-H "Authorization: Bearer $MONOSPACE_API_KEY"
await fetch('https://example.monospace.io/api/blog/items/articles/3', {
method: 'DELETE',
headers: {
Authorization: `Bearer ${process.env.MONOSPACE_API_KEY}`,
},
});
Next Steps
- Filtering — build advanced filters with logical operators and relational quantifiers
- Field Selection — select nested fields, use wildcards, and control response shape
- Relational Data — fetch and write related items in a single request
- SDK Installation — add type safety and autocomplete with the TypeScript SDK