POST forms

Create a Form.

Resource Path

/forms

Request Body

The request body is a JSON representation of the Form being created.

Example Request

Create a form with 3 fields.

POST https://api.swiftapp.com/v1/forms

POST DATA

{
   "name":"Dangerous Speech Categorisation",
   "fields":[
      {
         "title":"Language",
         "description":"Language the audience is being addressed in",
         "type":"mutiple",
         "required":false,
         "options":[
            "English",
            "Swahili",
            "Luo",
            "Kalenjin",
            "Luhya",
            "Kikuyu",
            "Sheng",
            "Other"
         ]
      },
      {
         "title":"Speaker",
         "description":"Description of the speaker",
         "type":"select",
         "required":false,
         "options":[
            "Politician",
            "Journalist",
            "Blogger",
            "Community Leader",
            "Anonymous Commenter",
            "Identifiable Commenter",
            "Public Figure"
         ]
      },
      {
         "title":"Target Audience",
         "description":"Audience most likely to react to this statement/article",
         "type":"text",
         "required":true
      }
   ]
}
Response
{
   "id":"99",
   "name":"Dangerous Speech Categorisation",
   "fields":[
      {
         "id":"23",
         "title":"Language",
         "description":"Language the audience is being addressed in",
         "type":"mutiple",
         "required":false,
         "options":[
            "English",
            "Swahili",
            "Luo",
            "Kalenjin",
            "Luhya",
            "Kikuyu",
            "Sheng",
            "Other"
         ]
      },
      {
         "id":"24",
         "title":"Speaker",
         "description":"Description of the speaker",
         "type":"select",
         "required":false,
         "options":[
            "Politician",
            "Journalist",
            "Blogger",
            "Community Leader",
            "Anonymous Commenter",
            "Identifiable Commenter",
            "Public Figure"
         ]
      },
      {
         "id":"25",
         "title":"Target Audience",
         "description":"Audience most likely to react to this statement/article",
         "type":"text",
         "required":true
      }
   ]
}

GET forms/:id

Returns the Form with the given :id.

Resource Path

/forms/:id

Request Parameters

Name

Type

Description

id

Required

The identifier for the desired form.

Example Request

GET https://api.swiftapp.com/v1/forms/1234

Response
{
   "id":"1234",
   "name":"Dangerous Speech categorisation",
   "fields":[
      {
         "id":"13",
         "title":"Language",
         "description":"Language the audience is being addressed in",
         "type":"mutiple",
         "required":false,
         "options":[
            "English",
            "Swahili",
            "Luo",
            "Kalenjin",
            "Luhya",
            "Kikuyu",
            "Sheng",
            "Other"
         ]
      },
      {
         "id":"14",
         "title":"Speaker",
         "description":"Description of the speaker",
         "type":"select",
         "required":false,
         "options":[
            "Politician",
            "Journalist",
            "Blogger",
            "Community Leader",
            "Anonymous Commenter",
            "Identifiable Commenter",
            "Public Figure"
         ]
      },
      {
         "id":"15",
         "title":"Target Audience",
         "description":"Audience most likely to react to this statement/article",
         "type":"text",
         "required":true
      }
   ]
}

PUT forms/:id

Modify an existing form. Fields cannot be modified from this end point and can only be modified via the field endpoints.

Resource Path

/forms/:id

Request Body

The request body is a JSON representation of the Form being updated.

Example Request

Rename a form.

PUT https://api.swiftapp.com/v1/forms/1234

PUT DATA

{
   "name":"Form Renamed",
}
Response
{
   "id":"1234",
   "name":"Form Renamed",
   "fields":[
      {
         "id":"13",
         "title":"Language",
         "description":"Language the audience is being addressed in",
         "type":"mutiple",
         "required":false,
         "options":[
            "English",
            "Swahili",
            "Luo",
            "Kalenjin",
            "Luhya",
            "Kikuyu",
            "Sheng",
            "Other"
         ]
      },
      {
         "id":"14",
         "title":"Speaker",
         "description":"Description of the speaker",
         "type":"select",
         "required":false,
         "options":[
            "Politician",
            "Journalist",
            "Blogger",
            "Community Leader",
            "Anonymous Commenter",
            "Identifiable Commenter",
            "Public Figure"
         ]
      },
      {
         "id":"15",
         "title":"Target Audience",
         "description":"Audience most likely to react to this statement/article",
         "type":"text",
         "required":true
      }
   ]
}

DELETE forms/:id

Delete a form.

Resource Path

/forms/:id

Request Parameters

Field

Type

Description

id

Required

The identifier for the desired form

Example Request

DELETE https://api.swiftapp.com/v1/forms/9999

POST forms/:id/fields

Add a new Field to a form.

Resource Path

/forms/:id/fields

Request Body

The request body is a JSON representation of the Field being added.

Request Parameters

Field

Type

Description

id

Required

The identifier for the desired form

Example Request

POST https://api.swiftapp.com/v1/forms/9999/fields

POST DATA

{
   "title":"Event",
   "description":"The event the statement is associated with",
   "type":"text",
   "required":false,
}
Response
{
   "id":"4321",
   "title":"Event",
   "description":"The event the statement is associated with",
   "type":"text",
   "required":false,
}

PUT forms/:id/fields/:field_id

Modify a field.

Resource Path

/forms/:id/fields/:field_id

Request Body

The request body is a JSON representation of the Field being modified.

Request Parameters

Field

Type

Description

id

Required

The numerical id of the desired form

field_id

Required

Account id of the field

Example Request

Below request makes a previously optional field, mandatory.

PUT https://api.swiftapp.com/v1/forms/9999/fields/4321

PUT DATA

{
   "required":true
}
Response
{
   "id":"4321",
   "title":"Event",
   "description":"The event the statement is associated with",
   "type":"text",
   "required":true,
}

DELETE forms/:id/fields/:field_id

Remove an existing account field. Only form owners can perform this action.

Resource Path

/forms/:id/fields/:field_id

Request Parameters

Field

Type

Description

id

Required

Identified for the the desired form.

field_id

Required

Identified for the field.

Example Request

DELETE https://api.swiftapp.com/v1/forms/9999/fields/345