### Get Survey Preview Response (200 OK) Source: https://github.com/enketo/enketo-api-docs/blob/master/_api/v2/2140-post-preview-survey.md Example of a successful response when retrieving a preview for an existing survey. The response includes the preview URL and the status code. ```json { "preview_url": "https://enke.to/preview/abcd", "code": 200 } ``` -------------------------------- ### GET Survey Endpoint Source: https://github.com/enketo/enketo-api-docs/blob/master/_includes/apidocs.html This GET endpoint is designed for testing the Enketo Smart Paper API within a browser environment. It does not initiate new surveys and is not intended for integration purposes. ```Jinja {% for doc in site.api %} {% if doc.categories[0] == nil or doc.categories[0] == version %} {% assign params = doc.params | map: 'name' | join: ' ' %} {% capture id %}{{doc.type | downcase}}{% for item in doc.categories offset:1 %}-{{ item }}{% endfor %}{% endcapture %} {% if id == "" %}{% assign id = doc.slug %}{% endif %} {% capture endpoint %} {% for item in doc.categories offset:1 %}/{{ item }}{% endfor %}{% endcapture %} [ {% if doc.type %}`**{{ doc.type }}** {{ endpoint }}` {% endif %}{{ doc.title }} ------------------------------------------------------------------------------- ](#/{{id}}) {{ doc.description | markdownify }} {% if doc.type == 'GET' and doc.categories[1] == 'survey' %} The GET version of this endpoint is only meant to test the Enketo Smart Paper API in the browser. It does not launch **new** surveys and is therefore not of use for integrating with Enketo. {% endif %} {% endif %} {% endfor %} ``` -------------------------------- ### Get Survey Preview (200 OK) Source: https://github.com/enketo/enketo-api-docs/blob/master/_api/v2/2050-get-preview-iframeable-survey.md This snippet demonstrates a successful response (HTTP 200 OK) when retrieving an existing iframe-able survey preview. The response includes the preview_iframe_url. ```json { "preview_iframe_url": "https://enke.to/preview/abcd", "code": 200 } ``` -------------------------------- ### Get Survey Views (JSON Response) Source: https://github.com/enketo/enketo-api-docs/blob/master/_api/v1/2160-post-all-survey.md This snippet shows the JSON response structure for the GET all survey views endpoint. It includes URLs for the survey, iframe, single view, and preview, along with a status code. ```json { "url": "https://enke.to/abcd", "iframe_url": "https://enke.to/i/abcd", "single_url": "https://enke.to/single/werdgag3e423gsgadgsd", "single_iframe_url": "https://enke.to/single/i/werdgag3e423gsgadgsd", "preview_url": "https://enke.to/preview/abcd", "preview_iframe_url": "https://enke.to/preview/i/abcd", "subdomain": "", "code": 200 } ``` -------------------------------- ### Get Single-Use Survey Response Source: https://github.com/enketo/enketo-api-docs/blob/master/_api/v1/2120-post-single-survey.md Upon a successful request to get a single-use survey, the Enketo API returns a JSON object. This object contains a `single_url` property, which is the link to the survey. The status code will be 200 for an existing survey or 201 for a newly created one. ```json { "single_url": "https://enke.to/single/abw3e325tt2gdsgsfd", "code": 200 } ``` -------------------------------- ### Get Iframeable Survey Preview (200 OK) Source: https://github.com/enketo/enketo-api-docs/blob/master/_api/v2/2150-post-preview-iframeable-survey.md This snippet demonstrates a successful response (Status: 200 OK) when retrieving an iframeable survey preview for an existing survey. The response includes the preview_iframe_url. ```json { "preview_iframe_url": "https://enke.to/preview/i/abcd", "code": 200 } ``` -------------------------------- ### Get Survey Preview (Existing) - 200 OK Source: https://github.com/enketo/enketo-api-docs/blob/master/_api/v2/2040-get-preview-survey.md This snippet demonstrates a successful response (200 OK) when retrieving an existing survey preview. The response includes a preview_url property pointing to the Enketo webform. ```json { "preview_url": "https://enke.to/preview/abcd", "code": 200 } ``` -------------------------------- ### Get Single Submit Iframe Survey (API v2) Source: https://github.com/enketo/enketo-api-docs/blob/master/_api/v2/2132-post-single-once-iframeable-survey.md This snippet demonstrates the response structure for obtaining a single-submit, iframe-able survey. It includes the `single_once_iframe_url` property and the HTTP status code. ```json { "single_once_iframe_url": "https://enke.to/single/abw3e325tt2gdsgsfd", "code": 200 } ``` -------------------------------- ### Get Survey PDF (API v2) Source: https://github.com/enketo/enketo-api-docs/blob/master/_api/v2/2055-get-view-pdf.md This endpoint retrieves a PDF of a survey. It supports various parameters to customize the output, such as format, margins, and landscape orientation. The response will be a PDF file on success or a JSON error object. ```HTTP GET /path/to/survey/{form_id}/pdf?server_url={server_url}&format={format}&margin={margin}&landscape={landscape} ``` -------------------------------- ### Get Launched Surveys (JSON Response) Source: https://github.com/enketo/enketo-api-docs/blob/master/_api/v1/3120-post-surveys-list.md This snippet shows the JSON response structure when successfully retrieving a list of launched surveys from the Enketo API. It includes a list of forms, each with server details and a URL, along with a status code. ```json { "forms": [ { "server_url": "https://myserver.com/bob", "form_id": "widgets", "url": "https://enke.to/abcd" }, { "server_url": "https://myserver.com/bob", "form_id": "Birds", "url": "https://enke.to/efgh" } ], "code": 200 } ``` -------------------------------- ### Get Survey Iframe URL (201 OK) Source: https://github.com/enketo/enketo-api-docs/blob/master/_api/v2/2154-post-view-iframeable.md This code snippet illustrates a successful response (Status: 201 OK) when creating or retrieving a new survey. It returns an object with the view_iframe_url and the status code. ```json { "view_iframe_url": "https://enke.to/view/abcd232agdf3434sgdra34", "code": 201 } ``` -------------------------------- ### Get Survey Iframe URL (200 OK) Source: https://github.com/enketo/enketo-api-docs/blob/master/_api/v2/2154-post-view-iframeable.md This code snippet demonstrates a successful response (Status: 200 OK) when retrieving an existing survey. It returns an object containing the view_iframe_url and the status code. ```json { "view_iframe_url": "https://enke.to/view/abcd232agdf3434sgdra34", "code": 200 } ``` -------------------------------- ### Get Survey Views (200 OK) Source: https://github.com/enketo/enketo-api-docs/blob/master/_api/v1/2060-get-all-survey.md This snippet shows the successful response (HTTP 200 OK) when retrieving all survey views. The response is a JSON object containing various URLs for the survey, including direct, iframe, and preview versions. ```json { "url": "https://enke.to/abcd", "iframe_url": "https://enke.to/i/abcd", "single_url": "https://enke.to/single/werdgag3e423gsgadgsd", "single_iframe_url": "https://enke.to/single/i/werdgag3e423gsgadgsd", "preview_url": "https://enke.to/preview/abcd", "preview_iframe_url": "https://enke.to/preview/i/abcd", "subdomain": "", "code": 200 } ``` -------------------------------- ### Get Existing Online-Only Survey (200 OK) Source: https://github.com/enketo/enketo-api-docs/blob/master/_api/v2/2000-get-survey.md This snippet demonstrates a successful response (200 OK) when retrieving an existing online-only survey. The response includes a JSON object with a 'url' property, which is the link to the launched survey. ```json { "url": "https://enke.to/abcd", "code": 200 } ``` -------------------------------- ### Get Single Iframe Survey (200 OK) Source: https://github.com/enketo/enketo-api-docs/blob/master/_api/v2/2030-get-single-iframeable-survey.md This code snippet demonstrates a successful response (200 OK) when retrieving an online-only, single-submit, iframe-able survey. The response body contains the URL for the survey and the status code. ```json { "single_iframe_url": "https://enke.to/single/i/abcd", "code": 200 } ``` -------------------------------- ### Get Launched Surveys (JSON Response) Source: https://github.com/enketo/enketo-api-docs/blob/master/_api/v1/3020-get-surveys-list.md This snippet shows the expected JSON response when successfully retrieving a list of launched surveys from the Enketo API. It includes a list of forms, each with its server URL, form ID, and a unique URL, along with a status code. ```json { "forms": [ { "server_url": "https://myserver.com/bob", "form_id": "widgets", "url": "https://enke.to/abcd" }, { "server_url": "https://myserver.com/bob", "form_id": "Birds", "url": "https://enke.to/efgh" } ], "code": 200 } ``` -------------------------------- ### Get Existing Iframe Survey (Enketo API) Source: https://github.com/enketo/enketo-api-docs/blob/master/_api/v2/2010-get-iframeable-survey.md This snippet demonstrates how to successfully retrieve an existing online-only survey that is compatible with iframes using the Enketo API. It expects a 200 OK status and returns a JSON object containing the iframe_url. ```json { "iframe_url": "https://enke.to/i/abcd", "code": 200 } ``` -------------------------------- ### Try Enketo API in Browser Source: https://github.com/enketo/enketo-api-docs/blob/master/_includes/apidocs.html Instructions for testing Enketo API endpoints directly in a web browser, including how to provide the API token. ```HTML [](#) ``` -------------------------------- ### Try Enketo API in Terminal Source: https://github.com/enketo/enketo-api-docs/blob/master/_includes/apidocs.html Guidance on how to interact with the Enketo API using terminal commands. ```Jinja {% if doc.type %} ### Try in terminal {% endif %} ``` -------------------------------- ### Load Instance for Viewing (201 OK) Source: https://github.com/enketo/enketo-api-docs/blob/master/_api/v2/4120-post-instance-view.md This snippet demonstrates a successful response (HTTP 201 OK) when loading an instance for viewing. It returns an object containing the view URL for the specified instance and form. ```json { "view_url": "https://enke.to/view/abcd232agdf3434sgdra34?instance_id=abcd", "code": 201 } ``` -------------------------------- ### Load Instance for Editing (201 OK) Source: https://github.com/enketo/enketo-api-docs/blob/master/_api/v2/4100-post-instance.md This code snippet demonstrates a successful response when loading an instance for editing. It returns a 201 OK status and an object containing a temporary edit URL. ```json { "edit_url": "https://enke.to/edit/abcd?instance_id=324sfasgsa324", "code": 201 } ``` -------------------------------- ### Get Single-Submit Survey URL (API v2) Source: https://github.com/enketo/enketo-api-docs/blob/master/_api/v2/2131-post-single-once-survey.md This snippet demonstrates how to call the Enketo API v2 to get a URL for a single-submit survey. The API returns a JSON object containing the `single_once_url` upon successful submission. It handles different status codes for existing or new submissions. ```json { "single_once_url": "https://enke.to/single/abw3e325tt2gdsgsfd", "code": 200 } ``` -------------------------------- ### Jekyll API Navigation Generation Source: https://github.com/enketo/enketo-api-docs/blob/master/_includes/apinav.html This snippet uses Jekyll's Liquid templating to iterate through site data, group API documentation by category, and generate navigation links. It handles conditional logic for displaying categories and links based on document properties. ```Liquid {% assign sites = site.data.navigation.sites %} {{ site.title }} ================ [v1](/v1) [v2](/v2) API Key Server URL Form ID Enketo URL {% for doc in site.api | group_by:"categories[1]" %} {% if doc.categories[0] == nil or doc.categories[0] == version %} {% assign newCategory = doc.categories[1] %} {% capture link %}{{doc.type | downcase}}{% for item in doc.categories offset:1 %}-{{ item }}{% endfor %}{% endcapture %} {% if oldCategory and oldCategory != newCategory %} {% endif %} {% if newCategory == nil %}* [{{ doc.title }}](#/{{ doc.slug }}) {% elsif newCategory != oldCategory %}* {{ newCategory }} ----------------- * [{{ doc.title }}](#/{{ link }}) {% elsif newCategory == oldCategory %}* [{{ doc.title }}](#/{{ link }}) {% endif %} {% assign oldCategory = newCategory %} {% endif %} {% endfor %} ``` -------------------------------- ### Get Survey (200 OK) Source: https://github.com/enketo/enketo-api-docs/blob/master/_api/v1/2000-get-survey.md Retrieves an offline-capable survey. If offline surveys are disabled on the Enketo server, an online-only survey is returned. The response includes a 'url' property if the survey has been launched previously. ```HTTP GET /api/v1/survey?server_url=...&form_id=... Status: 200 OK { "url": "https://enke.to/abcd", "code": 200 } ``` -------------------------------- ### API Request Parameters Source: https://github.com/enketo/enketo-api-docs/blob/master/_includes/apidocs.html Details the parameters for API requests, including their type (required/optional) and specific usage for various functionalities like server URL, form ID, themes, and attachments. ```Jinja {% for param in doc.params %}* {% if param.required == nil %}required {% else %}optional {% endif %} {% if param.name == 'server_url' %}parameter **`server_url`** is the url of the OpenRosa server your form is hosted on {% elsif param.name == 'form_id' %}parameter **`form_id`** is the ID of the form listed in _SERVER_/formList {% elsif param.name == 'theme' %}parameter **`theme`** can be used to centrally override the theme for all subsequent users, or to reset the theme with an empty string value {% elsif param.name == 'return_url' %}parameter **`return_url`** is the URL to redirect the user to after submission/close (default is a generic thank you page) {% elsif param.name == 'instance' %}parameter **`instance`** is the XML instance with _escaped quotation marks_ to be loaded {% elsif param.name == 'instance_id' %}parameter **`instance_id`** is the instanceID of the existing record to be loaded {% elsif param.name == 'instance_attachments' %}parameter **`instance_attachments[]`** can be used to pass attachments for the instance to be edited (`instance_attachments[file.name]=https://example.com`) {% elsif param.name == 'defaults' %}parameter **`defaults[]`** can be used to dynamically override survey field defaults (`defaults[/path/to/node]=value`) {% elsif param.name == 'parent_window_origin' %}parameter **`parent_window_origin`** can be used to safely enable an iframed survey to post messages back to the parent window {% elsif param.name == 'go_to' %}parameter **`go_to`** can be used to jump to a specific question upon load. It takes any XPath (`go_to=//question` or `go_to=//complex/repeat[3]//question`). {% elsif param.name == 'format' %}parameter **`format`** the paper format. Valid values are: `Letter, Legal, Tabloid, Ledger, A0, A1, A2, A3, A4, A5, and A6`. Default is `A4`. {% elsif param.name == 'margin' %}parameter **`margin`** the paper margin. Valid units are: `in, cm, and mm`. Example values are `2.1in, 2cm, 10mm`. Default is `0.5in`. {% elsif param.name == 'landscape' %}parameter **`landscape`** whether paper orientation is landscape. Valid values ar `true, false`. Default is `false`. {% endif %} {% endfor %} ``` -------------------------------- ### Get Read-Only Survey (200 OK) Source: https://github.com/enketo/enketo-api-docs/blob/master/_api/v2/2153-post-view.md This snippet demonstrates a successful response (200 OK) when retrieving an existing read-only survey. The response includes a 'view_url' property pointing to the survey. ```json { "view_url": "https://enke.to/view/abcd232agdf3434sgdra34", "code": 200 } ``` -------------------------------- ### API Response - Success (201 OK) Source: https://github.com/enketo/enketo-api-docs/blob/master/_api/v2/4142-post-instance-view-pdf.md This snippet shows a successful API response, indicating that the form instance was processed and a PDF was generated or is ready to be sent. The status code 201 signifies successful creation. ```http Status: 201 OK ``` -------------------------------- ### Get Offline Survey Response (JSON) Source: https://github.com/enketo/enketo-api-docs/blob/master/_api/v2/2111-post-survey-offline.md This snippet shows the JSON response structure when successfully retrieving an offline-capable survey. It includes the URL for the offline survey and the corresponding HTTP status code. ```JSON { "offline_url": "https://enke.to/abcd", "code": 200 } ``` -------------------------------- ### Get Launched Surveys (200 OK) Source: https://github.com/enketo/enketo-api-docs/blob/master/_api/v2/3020-get-surveys-list.md This snippet demonstrates a successful response (HTTP 200 OK) when retrieving the list of launched surveys. It returns an array of form objects, each containing details like server URL, form ID, and various Enketo URLs. ```json { "forms": [ { "server_url": "https://myserver.com/bob", "form_id": "widgets", "enketo_id": "abcd", "url": "https://enke.to/abcd", "iframe_url": "https://enke.to/i/abcd", "offline_url": "https://enke.to/x/abcd", "single_url": "https://enke.to/single/werdgag3e423gsgadgsd", "single_iframe_url": "https://enke.to/single/i/werdgag3e423gsgadgsd", "preview_url": "https://enke.to/preview/abcd", "preview_iframe_url": "https://enke.to/preview/i/abcd", "enketo_id": "abcd" }, { "server_url": "https://myserver.com/bob", "form_id": "birds", "enketo_id": "efgh", "url": "https://enke.to/efgh", "iframe_url": "https://enke.to/i/efgh", "offline_url": "https://enke.to/x/efgh", "single_url": "https://enke.to/single/abcag3e423gsgadgsd", "single_iframe_url": "https://enke.to/single/i/abcag3e423gsgadgsd", "preview_url": "https://enke.to/preview/efgh", "preview_iframe_url": "https://enke.to/preview/i/efgh", "enketo_id": "efgh" } ], "code": 200 } ``` -------------------------------- ### Load Instance for Editing (201 OK) Source: https://github.com/enketo/enketo-api-docs/blob/master/_api/v2/4110-post-instance-iframeable.md This code snippet demonstrates a successful response (HTTP status 201 OK) when loading an instance for editing. It returns an object containing an 'edit_url' property, which is a temporary URL to the editing interface. ```json { "edit_url": "https://enke.to/edit/i/abcd?instance_id=324sfasgsa324", "code": 201 } ``` -------------------------------- ### Get Read-Only Survey (200 OK) Source: https://github.com/enketo/enketo-api-docs/blob/master/_api/v2/2053-get-view.md This code snippet demonstrates a successful response (200 OK) when retrieving an existing read-only survey. It returns an object containing the view_url property. ```json { "view_url": "https://enke.to/view/abcd232agdf3434sgdra34", "code": 200 } ``` -------------------------------- ### API Response Status Codes Reference Source: https://github.com/enketo/enketo-api-docs/blob/master/_includes/apidocs.html Provides a link to documentation detailing response status codes for error handling in API interactions. ```Markdown For error responses, see the [response status codes documentation](#/1000-response-status-codes). ```