Update a form's definition
Replaces the whole definition of a form: questions, pages, logic, variables, hidden fields and settings. Needs the forms:write scope and editor access to the form. The body is the definition itself, in the format of the Form reference.
https://api.responsly.com/v1/forms/{form_id}/definition Save over the version you read
Section titled “Save over the version you read”Someone may be changing the same form in the editor while your code works on it. To never overwrite their change, every save names the version it starts from:
- Read the form with Get a form. Keep its
version(also theETagheader). - Change the definition.
- Send it with the version in the
If-Matchheader.
If the form has changed since you read it, even a moment before your save, nothing is saved and the answer is 412. Read the form again, apply your change to the new definition and send it once more. A save without If-Match is refused with 428.
Example
Section titled “Example”curl -X PUT https://api.responsly.com/v1/forms/Dg8Lz5ep/definition \ -H "Authorization: Bearer <token>" \ -H "Content-Type: application/json" \ -H 'If-Match: "3f1c2d8e9a0b4c5d6e7f8a9b0c1d2e3f4a5b6c7d8e9f0a1b2c3d4e5f6a7b8c9d"' \ -d @definition.jsonThe response is the saved form, in the same shape as Get a form, with its new version. The definition is included only for a token with the forms:read scope; a token that may only write gets the rest, enough for its next save. If the form was moved to another team or deleted right after the save, the answer has only its id.
Dry run
Section titled “Dry run”Add ?dry_run=1 to check a definition without saving it. The definition is validated and prepared as in a real save, so the answer lists what a save would really change:
{ "dry_run": true, "valid": true, "changes": { "questions": { "added": ["q7"], "removed": [], "changed": ["q1", "q3"] }, "sections": ["settings", "logic"] }}Questions are listed by ref, also those inside groups. sections names the other parts of the definition that would change.
What the save keeps
Section titled “What the save keeps”- The save is checked like a save from the editor, and the form keeps its version history.
settingsandthememust be JSON objects, andcomponents,welcome_pagesandend_pageslists of objects, as a form needs them to open.- The form password is not part of the API: the save keeps the password the form has, whatever
settings.password_protectionsays. Set or change it in the editor. - A form whose results are protected stays protected, whatever the definition says.
- Some settings are managed by Responsly for the whole team or account and keep their value.
theme.refmust be a public theme or one of the form’s team, and not deleted; otherwise the form keeps its theme. To change only the theme, use Set a form’s theme.
Errors
Section titled “Errors”| Status | Meaning |
|---|---|
403 | The token lacks forms:write, or the form belongs to another team or a workspace you cannot edit. |
412 | The form has changed since the version in If-Match, or it was moved to another workspace or deleted since. Nothing was saved. |
422 | The definition is not valid. The answer lists the problems. |
428 | The If-Match header is missing. |