Questionnaires
Create a questionnaire
Creates a new questionnaire. The questionnaireId (qst_xxx) is auto-generated. **Question key validation:** - Each question `key` must be a valid field key: dot-separated segments, each starting with a letter and containing only letters, numbers, and underscores (e.g. `questionnaire.filing_for`, `dateOfBirth`). - Each key must already exist in the field library for your tenant. Unknown keys are rejected with a 400 `UNKNOWN_FIELD_KEYS` error listing the offending keys. Create missing fields first via `POST /api/v1/field-library`, or look up existing keys via `GET /api/v1/field-library`.
Authorization
ApiKeyAuth X-API-Key<token>
API key generated from your Leadsail dashboard Settings page
In: header
Request Body
application/json
questions?array<>
Default
[]name*string
Length
1 <= lengthdescription?string
active?boolean
Default
trueResponse Body
application/json
application/json
application/json
package mainimport ( "fmt" "net/http" "io/ioutil" "strings")func main() { url := "https://api.leadsail.app/api/v1/questionnaires" body := strings.NewReader(`{ "name": "MVA Intake", "description": "Motor vehicle accident qualification questions", "active": true, "questions": [ { "key": "questionnaire.filing_for", "question": "Are you filing on behalf of yourself or someone else?", "options": [ "Self", "Someone else" ] } ] }`) req, _ := http.NewRequest("POST", url, body) req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := ioutil.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body))}{
"success": true,
"data": {
"questionnaireId": "qst_abc123",
"name": "string",
"description": "string",
"active": true,
"questions": [
{
"key": "filing_for",
"question": "Are you filing on behalf of yourself or someone else?",
"instructions": "string",
"options": [
"Self",
"Someone else"
]
}
],
"createdAt": "string",
"updatedAt": "string"
}
}{
"success": false,
"error": {
"code": "VALIDATION_ERROR",
"message": "Invalid input data",
"details": [
"string"
]
}
}{
"success": false,
"error": {
"code": "UNAUTHORIZED",
"message": "Authentication required"
}
}