Skip to content
EN

Using Public API (Write)

Last updated

This page explains how to create an item (POST) using Public API.

To make a model’s data postable via Public API, you need to enable that model on the Posting tab of the Public API page.

  1. Open the project’s Public API page

  2. Select the Posting tab

  3. Add at least one allowed origin. Requests from a browser are only accepted from the origins specified here

  4. Turn on the Enable toggle for the target model

  5. Click the Save Changes button

    Re:Earth CMS's Public API page, with the Posting tab selected, one allowed origin configured, and the target model's POST API Enable toggle turned on.

Click the Copy button on screen to copy the curl request.

Specify fields as JSON in a request to the POST /{model}/items endpoint to create a new item. No authentication is required. Replace the angle-bracketed placeholders such as <workspace_id_or_alias> with your actual values. The keys and values in fields depend on the target model’s field definitions. Here’s a sample.

Terminal window
curl -X POST 'https://api.cms.reearth.io/api/p/<workspace_id_or_alias>/<project_id_or_alias>/<model_id_or_key>/items' \
-H 'Content-Type: application/json' \
-d '{
"fields": {
"<field-key-1>": "<value-1>",
"<field-key-2>": "<value-2>"
}
}'