Create a field library entry
Creates a new field in the field library. **Key validation:** - The `key` must be dot-separated segments, each starting with a letter and containing only letters, numbers, and underscores (e.g. `filing_for`, `address.street`). Empty, malformed, or specially-charactered keys are rejected with a 400. - Keys are auto-prefixed by category when not already prefixed: `custom` → `customFields.`, `question` → `questionnaire.`, `attribution` → `attribution.params.`. For example, creating key `filing_for` with category `question` stores it as `questionnaire.filing_for`. - If the (prefixed) key already exists for your tenant, the request is rejected with a 409 Conflict.
Authorization
ApiKeyAuth API key generated from your Leadsail dashboard Settings page
In: header
Request Body
application/json
^[a-zA-Z][a-zA-Z0-9_]*(\.[a-zA-Z][a-zA-Z0-9_]*)*$1 <= length <= 2001 <= length <= 200"question" | "file" | "system" | "contact" | "attribution" | "compliance" | "flags" | "custom""string" | "number" | "boolean" | "date" | "file" | "array" | "object"falsetruetruetrueResponse Body
application/json
application/json
application/json
application/json
package mainimport ( "fmt" "net/http" "io/ioutil" "strings")func main() { url := "https://api.leadsail.app/api/v1/field-library" body := strings.NewReader(`{ "key": "filing_for", "label": "Filing For", "category": "question", "dataType": "string" }`) 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": {
"key": "first_name",
"label": "First Name",
"category": "question",
"dataType": "string",
"validationRules": {
"required": true,
"pattern": "string",
"minLength": 0,
"maxLength": 0,
"min": 0,
"max": 0
},
"isStandard": true,
"active": true,
"createdAt": "string",
"updatedAt": "string"
}
}{
"success": false,
"error": {
"code": "VALIDATION_ERROR",
"message": "Invalid input data",
"details": [
"string"
]
}
}{
"success": false,
"error": {
"code": "UNAUTHORIZED",
"message": "Authentication required"
}
}{
"success": false,
"error": {
"code": "CONFLICT",
"message": "Field with key \"questionnaire.filing_for\" already exists"
}
}Get a questionnaire
Returns a single questionnaire by ID, including its full list of questions with keys, text, instructions, and predefined options.
List field library entries
Returns all field library entries for the authenticated tenant. The field library is a central registry of all internal field keys used in conditional logic, questionnaires, posting specs, and prompt templates. Filter by category to get fields of a specific type.