Connect with FastAPI
Forward validated server-side form data from a FastAPI endpoint.
Requirements
Install FastAPI, httpx and email-validator (required for EmailStr). Create a server route and configure PANTHER_HOOK_TOKEN as a deployment secret.
Protected ingestion uses POST /api/v1/forms/:formId/submissions with Authorization: Bearer and submissions:create scope.
Configure and test
Step 1: Copy credentials or form key
Create a scoped workspace token in API Tokens and store it in the server or hosting platform secret store.
Step 2: Add the request
Validate incoming fields and add rate limiting to your own public endpoint. Never pass the bearer token back to the browser.
Step 3: Send a test
Use test: true in the JSON request or run the form setup test tool.
Step 4: Verify and launch
Open Submissions and filter by Test to verify captured field values. Configure enabled destinations and inspect Deliveries separately.
Example
This FastAPI example uses standard HTTP. Panther Hook does not require a framework-specific SDK; replace all placeholder identifiers with real form values.
import os
import httpx
from fastapi import FastAPI
from pydantic import BaseModel, EmailStr
app = FastAPI()
class Lead(BaseModel):
email: EmailStr
message: str
@app.post('/contact')
async def contact(lead: Lead):
async with httpx.AsyncClient(timeout=10) as client:
response = await client.post(
'https://pantherhook.com/api/v1/forms/YOUR_FORM_ID/submissions',
headers={'Authorization': 'Bearer ' + os.environ['PANTHER_HOOK_TOKEN']},
json=lead.model_dump(),
)
response.raise_for_status()
return response.json()Troubleshoot
- Unexpected 4xx: check endpoint, scope or allowed origin and required fields.
- 429: respect rate limits and avoid unbounded retries.
- Accepted lead but missing notification: inspect the relevant destination and spam classification separately.
