LeadSail
Files

Create or update a file

Creates or updates a file reference for a lead. Upserts by leadId + fileKey — if a file with the same key already exists, it will be updated. The file must already be hosted at a publicly accessible URL.

POST
/api/v1/files

Authorization

ApiKeyAuth
X-API-Key<token>

API key generated from your Vayaflow dashboard Settings page

In: header

Request Body

application/json

leadId*string

Lead ID to associate the file with

Length1 <= length
fileKey*string

Unique key for this file type (lowercase alphanumeric + underscores, e.g. "retainer_signed")

Length1 <= length
fileName*string

Original filename (e.g. "retainer_signed.pdf")

Length1 <= length
fileType*string

File extension (e.g. "pdf", "png", "jpg")

Length1 <= length
documentUrl*string

Publicly accessible URL to the file

Formaturi
signingUrl?string

Signing provider URL (if applicable)

Formaturi
provider?string

Source of the file

Value in"docuseal" | "manual_upload" | "system_generated" | "csv_import"
providerDocumentId?string

External provider document ID

status?string

Initial status (defaults to "pending")

Value in"pending" | "uploaded" | "viewed" | "in_progress" | "signed" | "verified" | "expired" | "declined" | "failed"
signedAt?string

ISO 8601 timestamp when document was signed

createdBySubmissionId?string

Submission ID that created this file

metadata?

Provider-specific metadata

Response Body

application/json

application/json

application/json

package mainimport (  "fmt"  "net/http"  "io/ioutil"  "strings")func main() {  url := "https://api.leadsail.app/api/v1/files"  body := strings.NewReader(`{    "leadId": "lead_xyz789",    "fileKey": "retainer_signed",    "fileName": "retainer_signed.pdf",    "fileType": "pdf",    "documentUrl": "https://storage.example.com/files/retainer_signed.pdf",    "status": "uploaded"  }`)  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": {
    "fileId": "file_abc123",
    "leadId": "lead_xyz789",
    "fileKey": "retainer_signed",
    "fileName": "retainer_signed.pdf",
    "fileType": "pdf",
    "documentUrl": "https://storage.example.com/files/retainer_signed.pdf",
    "status": "signed",
    "provider": "docuseal",
    "createdAt": "2024-06-15T10:30:00Z",
    "updatedAt": "2024-06-15T14:22:00Z",
    "signedAt": "2024-06-15T14:22:00Z"
  }
}
{
  "success": false,
  "error": {
    "code": "VALIDATION_ERROR",
    "message": "Invalid input data",
    "details": [
      "string"
    ]
  }
}
{
  "success": false,
  "error": {
    "code": "UNAUTHORIZED",
    "message": "Authentication required"
  }
}