Grawt API Documentation
Overview
The Grawt API allows you to programmatically manage leads, tags, and custom fields in your Grawt account. This RESTful API uses JSON for request and response bodies.
Base URL: https://grawt.app/api/v1
Authentication
All API requests require authentication using an API key. Include your API key in the request header.
| Header | Value |
|---|---|
X-API-Key |
Your API key |
Example:
curl -H "X-API-Key: your-api-key" https://grawt.app/api/v1/leads/fields
Error Responses
| Status Code | Description |
|---|---|
| 400 | Missing API key |
| 401 | Invalid API key |
Leads
Add Lead
Creates a new lead in your account.
Endpoint: POST /api/v1/leads
Request Body:
| Field | Type | Required | Description |
|---|---|---|---|
email |
string | Yes | Lead's email address |
fields |
object | Yes | Lead data fields (use Get Lead Fields to see available fields) |
Example Request:
{
"email": "john@example.com",
"fields": {
"first_name": "John",
"last_name": "Doe",
"phone": "+1234567890"
}
}
Success Response (201):
{
"success": true,
"message": "Lead added successfully."
}
Update Lead
Updates an existing lead by email address.
Endpoint: PUT /api/v1/leads/{email}
URL Parameters:
| Parameter | Type | Description |
|---|---|---|
email |
string | Lead's email address |
Request Body:
| Field | Type | Required | Description |
|---|---|---|---|
fields |
object | Yes | Lead data fields to update |
Example Request:
{
"fields": {
"first_name": "Jonathan",
"phone": "+1987654321"
}
}
Success Response (200):
{
"success": true,
"message": "Lead successfully updated."
}
Error Response (404):
{
"success": false,
"message": "Lead not found."
}
Sync Lead
Creates a new lead or updates an existing one based on the email address. This is useful for upsert operations where you want to ensure the lead exists with the latest data.
Endpoint: POST /api/v1/leads/sync
Request Body:
| Field | Type | Required | Description |
|---|---|---|---|
email |
string | Yes | Lead's email address |
fields |
object | Yes | Lead data fields |
add_tags |
array | No | Array of tag IDs to apply to the lead |
remove_tags |
array | No | Array of tag IDs to remove from the lead |
Example Request:
{
"email": "john@example.com",
"fields": {
"first_name": "John",
"last_name": "Doe",
"phone": "+1234567890"
},
"add_tags": [1, 5, 12],
"remove_tags": [3]
}
Success Response (200):
{
"success": true,
"message": "Lead successfully created."
}
or
{
"success": true,
"message": "Lead successfully updated."
}
Delete Lead
Permanently deletes a lead by email address.
Endpoint: DELETE /api/v1/leads/{email}
URL Parameters:
| Parameter | Type | Description |
|---|---|---|
email |
string | Lead's email address |
Success Response (200):
{
"success": true,
"message": "Lead deleted successfully."
}
Error Response (404):
{
"success": false,
"message": "Lead not found."
}
Error Response (422):
{
"success": false,
"message": "The email ID is required and must be a valid email address."
}
Apply Tags to Lead
Applies one or more tags to an existing lead.
Endpoint: POST /api/v1/leads/{email}/tags
URL Parameters:
| Parameter | Type | Description |
|---|---|---|
email |
string | Lead's email address |
Request Body:
| Field | Type | Required | Description |
|---|---|---|---|
tags |
array | Yes | Array of tag IDs to apply |
Example Request:
{
"tags": [1, 5, 12]
}
Success Response (200):
{
"success": true,
"message": "Tags applied successfully."
}
Error Response (404):
{
"success": false,
"message": "Lead not found."
}
Remove Tags from Lead
Removes one or more tags from an existing lead.
Endpoint: DELETE /api/v1/leads/{email}/tags
URL Parameters:
| Parameter | Type | Description |
|---|---|---|
email |
string | Lead's email address |
Request Body:
| Field | Type | Required | Description |
|---|---|---|---|
tags |
array | Yes | Array of tag IDs to remove |
Example Request:
{
"tags": [3, 7]
}
Success Response (200):
{
"success": true,
"message": "Tags removed successfully."
}
Error Response (404):
{
"success": false,
"message": "Lead not found."
}
Get Lead Fields
Retrieves all available custom fields for leads in your account.
Endpoint: GET /api/v1/leads/fields
Success Response (200):
{
"success": true,
"user_lead_fields": [
{
"key": "first_name",
"label": "First Name",
"type": "text"
},
{
"key": "last_name",
"label": "Last Name",
"type": "text"
},
{
"key": "phone",
"label": "Phone",
"type": "text"
}
]
}
Tags
Get Tags
Retrieves all tags in your account.
Endpoint: GET /api/v1/tags
Success Response (200):
{
"success": true,
"tags": [
{
"id": 1,
"name": "Customer"
},
{
"id": 5,
"name": "Newsletter"
},
{
"id": 12,
"name": "VIP"
}
]
}
Error Handling
All endpoints return consistent error responses.
Validation Errors (422)
When request validation fails:
{
"message": "The email field is required.",
"errors": {
"email": ["The email field is required."]
}
}
Common Error Codes
| Status Code | Description |
|---|---|
| 400 | Bad Request - Missing API key |
| 401 | Unauthorized - Invalid API key |
| 404 | Not Found - Resource doesn't exist |
| 422 | Unprocessable Entity - Validation error |
| 500 | Internal Server Error |
Rate Limiting
API requests are subject to rate limiting. If you exceed the limit, you'll receive a 429 Too Many Requests response.
Best Practices
Security
- Never expose your API key in client-side code (JavaScript, React, Vue, etc.)
- Store your API key in environment variables on your server
- Use server-to-server communication for API calls
Recommended Architecture
[Client Browser] → [Your Backend Server] → [Grawt API]
Your frontend should submit data to your own backend, which then makes authenticated requests to the Grawt API.
Quick Reference
| Endpoint | Method | Description |
|---|---|---|
/api/v1/leads |
POST | Add a new lead |
/api/v1/leads/{email} |
PUT | Update an existing lead |
/api/v1/leads/sync |
POST | Create or update a lead (upsert) |
/api/v1/leads/{email} |
DELETE | Delete a lead |
/api/v1/leads/{email}/tags |
POST | Apply tags to a lead |
/api/v1/leads/{email}/tags |
DELETE | Remove tags from a lead |
/api/v1/leads/fields |
GET | Get available lead fields |
/api/v1/tags |
GET | Get all tags |