LeadSail
Field Library

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.

POST
/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

key*string
Match^[a-zA-Z][a-zA-Z0-9_]*(\.[a-zA-Z][a-zA-Z0-9_]*)*$
Length1 <= length <= 200
label*string
Length1 <= length <= 200
category*string
Value in"question" | "file" | "system" | "contact" | "attribution" | "compliance" | "flags" | "custom"
dataType?string
Value in"string" | "number" | "boolean" | "date" | "file" | "array" | "object"
validationRules?
isStandard?boolean
Defaultfalse
isEditable?boolean
Defaulttrue
isDeletable?boolean
Defaulttrue
active?boolean
Defaulttrue

Response 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"
  }
}