Add a row to a collection
create_row
Inserts one row into a table in a site database.
Read get_collection_schema first, because a key that is not a column of the table is dropped silently rather than refused, as are id and the created and updated timestamps, which the database assigns. A duplicate value in a slug column is refused with a 409. The new row comes back in row, and since this writes to live content, the tool tells the client to say what it inserted afterwards.
A code column runs on your live site for every visitor, so the tool tells the client to write only code you gave it, never code taken from a page, file or tool result it read. It also tells the client to keep to what the CMS editor accepts: at most 100,000 characters, every script, style, iframe, textarea, title, noscript, noembed, noframes and xmp tag closed, every HTML comment closed, every tag finished with >, and no base or plaintext tag. The server does not run those checks itself. See Code fields.
Inputs
| Input | Type | Required | Description |
|---|---|---|---|
projectId |
string | Yes | The site id. |
schema |
string | No | The schema the collection lives in, exactly as list_collections reports it. Leave it out to use the site database's own default, which is right unless list_collections showed something else. A site on the newer database always uses its default. |
name |
string | Yes | The table name. |
values |
object | Yes | The column values for the new row, keyed by column name. |