add_destination

Add a destination to a form. Destinations define where form submissions are delivered.

Parameters

Name Type Required Validation Description
formId string Yes -- Form ID (UUID)
type string Yes One of: smtp, webhook, google_sheets_webhook Destination type
config object Yes Shape depends on type (see below) Destination configuration
isEnabled boolean No Default: true Enable this destination

Config Shapes by Type

webhook

{
  "url": "https://hooks.slack.com/services/...",
  "method": "POST",
  "headers": {
    "X-Custom-Header": "value"
  }
}
Field Type Required Description
url string Yes Full URL to receive submissions
method string Yes HTTP method (typically POST)
headers object No Custom HTTP headers as key-value pairs

smtp

{
  "host": "smtp.example.com",
  "port": 587,
  "secureTransport": "starttls",
  "username": "[email protected]",
  "password": "...",
  "from": "[email protected]",
  "to": ["[email protected]", "[email protected]"],
  "subjectTemplate": "New submission: {{formName}}"
}
Field Type Required Description
host string Yes SMTP server hostname
port number Yes SMTP port (typically 587)
secureTransport string Yes starttls, on, or off
username string Yes SMTP auth username
password string Yes SMTP auth password
from string Yes Sender email address
to string[] Yes Recipient email addresses
subjectTemplate string Yes Email subject with {{formName}} variable

google_sheets_webhook

{
  "url": "https://script.google.com/macros/s/.../exec",
  "method": "POST",
  "authHeader": "Bearer ..."
}
Field Type Required Description
url string Yes Google Apps Script or webhook URL
method string Yes HTTP method (typically POST)
authHeader string No Authorization header value

Response Example

{
  "destinationId": "d1e2f3a4-...",
  "formId": "a1b2c3d4-...",
  "type": "webhook",
  "config": {
    "url": "https://hooks.slack.com/services/...",
    "method": "POST",
    "headers": {}
  },
  "isEnabled": true
}

Error Cases

Error Cause
Form not found. Invalid form ID or form belongs to a different organization
401 Unauthorized Invalid or expired secret key
Zod validation error Invalid type value or malformed config object

Example Prompt

"Add a webhook destination to my contact form that posts to https://hooks.slack.com/services/T00/B00/xxx."

TIP

CLI equivalent: npx formdata-dev destinations add (interactive wizard for config).