Fields

Create Field

Add Field

This endpoint allows you to add a new field.

Request Body

  • description (string, required): A description of the field.

  • name (string, required): The name of the field.

  • type (string, required): The type of the field.

  • privacyMode (string, required): The privacy mode of the field. "public" or "private".

Response

The response will contain the details of the newly added field.

post/fields

Request

  • Base URL: https://api.speakai.co/v1
  • URL: https://api.speakai.co/v1/fields
  • Auth: API key in header x-speakai-key and API key in header x-access-token

Request body

namestring required

Name the field. This is the label you see in the app and the name you match on when you set values later. Required. Trimmed. No minimum or maximum length. The server trims the name and looks for an existing field with the same name in your company, so a duplicate returns 409, not 400.

descriptionstring

Describe what the field is for. You can send an empty string. Optional. Empty string is accepted. the schema does not trim it, but the create helper trims it before saving and stores an empty string when you leave it out.

type'text' | 'url' | 'boolean' | 'date' | 'datetime' | 'number' | 'currency' required

Set the data type the field stores. Required. Trimmed. The schema schema writes.allow(FieldType), which passes the enum object as an extra allowed value rather than constraining the string, so the validator accepts any non-empty string. An empty string is still rejected. A value outside the list fails when the field is saved, so a value outside the list fails when the field is saved.

isActiveboolean

Set whether the field is active. Leave it out and the field is created active. Optional. The declared default is true, but the middleware only reads the validation error and discards the converted value. The default that actually applies comes from the create helper, which defaults the parameter to true, matching the model default.

privacyMode'public' | 'private'

Choose whether values for this field are visible publicly or kept private. Optional. Trimmed. Same.allow(MediaPrivacyMode) pattern as type, so the validator accepts any non-empty string and the model enforces the list. Leave it out and the model default applies, which is public.

promptstring

Give the AI an instruction for filling this field automatically. Optional. Trimmed. Empty string is accepted.

allowedValuesstring[]

List the values a user can pick for this field. Optional. Every item must be a string. No cap on the number of items. Leave it out and the field is created with an empty list.

allowedValuesMode'single' | 'multiple'

Choose whether a user can pick one value from allowedValues or several. Optional. This is the one property the schema really constrains, with.valid(.Object.values(AllowedValuesMode)), so anything outside the list returns 400. the schema also declares.default('multiple'), but the middleware discards converted values, so the default that applies comes from the create helper (multiple.

otherValuesboolean

Allow a user to enter a value that is not in allowedValues. Optional. Leave it out and it is stored as false.

notApplicableValuesstring

Set the text that marks this field as not applicable for a piece of media. Optional. Empty string is accepted. Leave it out and it is stored as an empty string.

Response

Success

Changes

No recorded changes to this operation across all 2 revisions of this API.