REST API Datasource - Complete Guide
๐ Connect REST APIsโ
HTTP Methods ยท Authentication ยท Headers ยท Query Params ยท Request Body
๐ Table of Contentsโ
- Overview
- General Configuration
- Authentication
- Headers Configuration
- Query Parameters
- Request Body
- Advanced Options
- Testing Connection
- Examples
Overviewโ
Jet Admin's REST API connector enables you to integrate with any RESTful web service:
- โ All HTTP Methods - GET, POST, PUT, DELETE, PATCH
- โ Multiple Auth Types - None, Basic, Bearer, OAuth2
- โ Custom Headers - Add any HTTP header
- โ Query Parameters - Dynamic URL parameters
- โ Request Body - JSON, XML, or plain text
- โ SSL/TLS - Secure HTTPS connections
- โ Timeout Control - Configurable request timeouts
Use Cases:
- Payment gateways (Stripe, PayPal)
- Communication services (Twilio, SendGrid)
- CRM systems (Salesforce, HubSpot)
- Custom internal APIs
- Third-party data services
General Configurationโ
Required Fieldsโ
| Field | Type | Required | Default | Options | Description |
|---|---|---|---|---|---|
| Base URL | String | โ Yes | - | Valid URL | Root URL of the REST API |
| Method | String | โ Yes | GET | GET, POST, PUT, DELETE, PATCH | HTTP method for requests |
Optional Fieldsโ
| Field | Type | Required | Default | Validation | Description |
|---|---|---|---|---|---|
| Timeout | Integer | โ No | 30 | Min: 1 | Request timeout in seconds |
| Content Type | String | โ No | application/json | application/json, application/xml, text/plain | Default Content-Type header |
Base URLโ
Purpose: The root endpoint of the REST API.
Format: https://domain.com or https://domain.com/api/v1
Examples:
โ
https://api.stripe.com/v1
โ
https://api.twilio.com/2010-04-01
โ
https://api.example.com
โ
https://hooks.slack.com/services
โ api.example.com (missing protocol)
โ http:// (use https for production)
Best Practices:
- Always use HTTPS in production
- Include version path if API is versioned
- Don't include trailing slash (unless required)
- Keep environment-specific URLs separate
HTTP Methodโ
Purpose: The HTTP verb for API requests.
Available Methods:
| Method | Use Case | Has Body | Idempotent |
|---|---|---|---|
| GET | Retrieve resources | โ No | โ Yes |
| POST | Create resources | โ Yes | โ No |
| PUT | Update/replace resources | โ Yes | โ Yes |
| PATCH | Partial update | โ Yes | โ No |
| DELETE | Delete resources | โ No | โ Yes |
When to Use Each:
GET - Fetch data without side effects
GET /users/123
GET /orders?status=pending
POST - Create new resources
POST /users
POST /orders
PUT - Replace entire resource
PUT /users/123
PATCH - Partial update
PATCH /users/123
DELETE - Remove resources
DELETE /users/123
Timeoutโ
Purpose: Maximum time to wait for API response.
Type: Integer (seconds)
Default: 30 seconds
Recommended Values:
- Fast APIs:
10seconds - Standard APIs:
30seconds - Slow external APIs:
60seconds - File uploads:
120seconds
When to Adjust:
- Increase for slow external services
- Increase for large file transfers
- Decrease for real-time applications
Content Typeโ
Purpose: Default Content-Type header for requests.
Options:
application/json(Default)application/xmltext/plain
Override Per Request: You can override this in the Headers section for specific requests.
Authenticationโ
Jet Admin supports 4 authentication types for REST APIs:
1. No Authentication (none)โ
Use Case: Public APIs that don't require authentication
Configuration:
{
"authType": "none"
}
Examples:
- Public data APIs
- Webhooks (incoming)
- Open government data
2. Basic Authentication (basic)โ
Use Case: APIs using HTTP Basic Auth
Fields:
| Field | Type | Required | Description |
|---|---|---|---|
| Username | String | โ Yes | API username or key |
| Password | String | โ Yes | API password or secret |
Configuration:
{
"authType": "basic",
"username": "api_key_here",
"password": "api_secret_here"
}
How It Works:
- Credentials are base64 encoded
- Sent in
Authorization: Basic <encoded>header - Automatically handled by Jet Admin
Examples:
SendGrid:
{
"authType": "basic",
"username": "apikey",
"password": "SG.xxxxxxxxxxxxxxxxxx"
}
Custom API:
{
"authType": "basic",
"username": "myuser",
"password": "mypassword"
}
3. Bearer Token (bearer)โ
Use Case: APIs using token-based authentication
Fields:
| Field | Type | Required | Description |
|---|---|---|---|
| Bearer Token | String | โ Yes | JWT, API token, or access token |
Configuration:
{
"authType": "bearer",
"bearerToken": "your-token-here"
}
How It Works:
- Token sent in
Authorization: Bearer <token>header - Automatically handled by Jet Admin
Examples:
Stripe:
{
"authType": "bearer",
"bearerToken": "sk_test_xxxxxxxxxxxxxxxxxx"
}
GitHub API:
{
"authType": "bearer",
"bearerToken": "ghp_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
}
Custom JWT:
{
"authType": "bearer",
"bearerToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
}
4. OAuth2 (oauth2)โ
Use Case: APIs requiring OAuth2 authentication flow
Fields:
| Field | Type | Required | Description |
|---|---|---|---|
| Client ID | String | โ Yes | OAuth2 client identifier |
| Client Secret | String | โ Yes | OAuth2 client secret |
| Token URL | String | โ Yes | OAuth2 token endpoint URL |
Configuration:
{
"authType": "oauth2",
"oauth2": {
"clientId": "your-client-id",
"clientSecret": "your-client-secret",
"tokenUrl": "https://auth.example.com/oauth/token"
}
}
How It Works:
- Jet Admin requests access token from token URL
- Token is cached for subsequent requests
- Token automatically refreshed when expired
- Access token sent in
Authorization: Bearer <token>header
Examples:
Google APIs:
{
"authType": "oauth2",
"oauth2": {
"clientId": "123456789-abcdefg.apps.googleusercontent.com",
"clientSecret": "GOCSPX-xxxxxxxxxxxxxxxxx",
"tokenUrl": "https://oauth2.googleapis.com/token"
}
}
Microsoft Graph:
{
"authType": "oauth2",
"oauth2": {
"clientId": "your-app-id",
"clientSecret": "your-app-secret",
"tokenUrl": "https://login.microsoftonline.com/common/oauth2/v2.0/token"
}
}
Custom OAuth2:
{
"authType": "oauth2",
"oauth2": {
"clientId": "client-123",
"clientSecret": "secret-456",
"tokenUrl": "https://api.example.com/oauth/token"
}
}
Headers Configurationโ
Purposeโ
Add custom HTTP headers to all requests made to the REST API.
Header Structureโ
| Field | Type | Required | Description |
|---|---|---|---|
| Key | String | โ Yes | Header name |
| Value | String | โ Yes | Header value |
Common Headersโ
| Header | Value | Use Case |
|---|---|---|
Accept | application/json | Specify response format |
Content-Type | application/json | Specify request format |
X-API-Key | your-api-key | Custom API key header |
X-Request-ID | unique-id | Request tracking |
User-Agent | JetAdmin/1.0 | Custom user agent |
Adding Headersโ
Example 1: Custom API Key
{
"headers": [
{
"key": "X-API-Key",
"value": "your-api-key-here"
}
]
}
Example 2: Multiple Headers
{
"headers": [
{
"key": "Accept",
"value": "application/json"
},
{
"key": "X-API-Key",
"value": "secret-key"
},
{
"key": "X-Request-ID",
"value": "req-123456"
}
]
}
Example 3: Override Content-Type
{
"headers": [
{
"key": "Content-Type",
"value": "application/xml"
}
]
}
Dynamic Headers with Variablesโ
Use Jet Admin variables in header values:
X-User-ID: {{ctx.input.userId}}
X-Tenant-ID: {{ctx.tenant.id}}
Authorization: Bearer {{ctx.auth.token}}
Query Parametersโ
Purposeโ
Add URL query parameters to API requests.
Parameter Structureโ
| Field | Type | Required | Description |
|---|---|---|---|
| Key | String | โ Yes | Parameter name |
| Value | String | โ Yes | Parameter value |
Adding Query Parametersโ
Example 1: Simple Parameters
{
"queryParams": [
{
"key": "status",
"value": "active"
},
{
"key": "limit",
"value": "100"
}
]
}
Result:
GET /users?status=active&limit=100
Example 2: Array Parameters
{
"queryParams": [
{
"key": "ids",
"value": "1,2,3"
}
]
}
Result:
GET /users?ids=1,2,3
Example 3: Dynamic Parameters
{
"queryParams": [
{
"key": "userId",
"value": "{{ctx.input.userId}}"
},
{
"key": "date",
"value": "{{ctx.input.date}}"
}
]
}
Common Query Parametersโ
| Parameter | Example | Use Case |
|---|---|---|
limit | ?limit=100 | Pagination - max results |
offset | ?offset=20 | Pagination - skip results |
page | ?page=2 | Page number |
sort | ?sort=created_at | Sort field |
order | ?order=desc | Sort direction |
filter | ?filter=status:active | Filter criteria |
search | ?search=john | Search query |
fields | ?fields=id,name,email | Field selection |
Request Bodyโ
Purposeโ
Send data in the request body for POST, PUT, and PATCH requests.
When to Useโ
| Method | Body Required | Typical Use |
|---|---|---|
| POST | โ Usually | Create resource |
| PUT | โ Yes | Replace resource |
| PATCH | โ Yes | Update resource |
| GET | โ No | Retrieve data |
| DELETE | โ No | Delete resource |
Body Formatโ
Type: String (JSON, XML, or plain text)
Default Content-Type: application/json
JSON Body Examplesโ
Example 1: Create User
{
"body": "{\"name\":\"John Doe\",\"email\":\"john@example.com\",\"role\":\"user\"}"
}
Formatted:
{
"name": "John Doe",
"email": "john@example.com",
"role": "user"
}
Example 2: Update Order
{
"body": "{\"status\":\"shipped\",\"trackingNumber\":\"1Z999AA10123456784\"}"
}
Example 3: Complex Nested Object
{
"body": "{\"user\":{\"name\":\"John\",\"address\":{\"city\":\"NYC\",\"zip\":\"10001\"}},\"sendEmail\":true}"
}
Using Variables in Bodyโ
Example 1: Input Parameters
{
"body": "{\"userId\":\"{{ctx.input.userId}}\",\"action\":\"{{ctx.input.action}}\"}"
}
Example 2: Previous Node Output
{
"body": "{\"orderId\":\"{{ctx.fetchOrder.result.id}}\",\"status\":\"processed\"}"
}
Example 3: Mixed Variables
{
"body": "{\"tenantId\":\"{{ctx.tenant.id}}\",\"createdBy\":\"{{ctx.user.email}}\",\"data\":{{ctx.transform.result}}}"
}
XML Body Exampleโ
{
"contentType": "application/xml",
"body": "<user><name>John Doe</name><email>john@example.com</email></user>"
}
Plain Text Exampleโ
{
"contentType": "text/plain",
"body": "Simple text message"
}
Advanced Optionsโ
Follow Redirectsโ
Purpose: Automatically follow HTTP 3xx redirects.
Type: Boolean
Default: true
When to Disable:
- Security requirements
- Debugging redirect issues
- When redirect handling is custom
Configuration:
{
"followRedirects": false
}
SSL Verificationโ
Purpose: Verify SSL certificates for HTTPS connections.
Type: Boolean
Default: true
When to Disable:
- Development with self-signed certificates
- Testing environments
- Internal APIs without proper SSL
โ ๏ธ Warning: Disabling SSL verification reduces security. Only use in development!
Configuration:
{
"sslVerify": false
}
Testing Connectionโ
How to Testโ
- Configure REST API datasource
- Set method to GET (for testing)
- Add any required authentication
- Click "Test Connection"
- Review response
Test Resultsโ
โ Successโ
โโโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโ
โ โ Connection Successful! โ
โ โ
โ URL: https://api.example.com/health โ
โ Method: GET โ
โ Status: 200 OK โ
โ Response Time: 125ms โ
โ โ
โ Response: โ
โ {"status": "healthy", "version": "1.0"}โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Failureโ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ โ Connection Failed โ
โ โ
โ URL: https://api.example.com/users โ
โ Method: GET โ
โ Status: 401 Unauthorized โ
โ โ
โ Error: Invalid API key โ
โ โ
โ Troubleshooting: โ
โ โข Verify authentication credentials โ
โ โข Check API key is valid โ
โ โข Ensure API endpoint is correct โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Common Test Errorsโ
| Error | Status | Cause | Solution |
|---|---|---|---|
400 Bad Request | 400 | Invalid request format | Check body, headers, parameters |
401 Unauthorized | 401 | Authentication failed | Verify API key/token |
403 Forbidden | 403 | Insufficient permissions | Check API permissions |
404 Not Found | 404 | Invalid URL | Verify base URL and endpoint |
429 Too Many Requests | 429 | Rate limit exceeded | Wait and retry, check rate limits |
500 Internal Server Error | 500 | API server error | Contact API provider |
502 Bad Gateway | 502 | API gateway error | Retry later |
503 Service Unavailable | 503 | API down | Check API status page |
Examplesโ
Example 1: Stripe API (Bearer Token)โ
{
"baseUrl": "https://api.stripe.com/v1",
"method": "GET",
"timeout": 30,
"authType": "bearer",
"bearerToken": "sk_test_xxxxxxxxxxxxxxxxxx",
"headers": [
{
"key": "Stripe-Version",
"value": "2022-11-15"
}
],
"queryParams": [
{
"key": "limit",
"value": "10"
}
],
"contentType": "application/json",
"followRedirects": true,
"sslVerify": true
}
Usage in Query:
GET /charges?limit=10
Example 2: Twilio API (Basic Auth)โ
{
"baseUrl": "https://api.twilio.com/2010-04-01",
"method": "POST",
"timeout": 30,
"authType": "basic",
"username": "ACxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"password": "your_auth_token",
"headers": [
{
"key": "Content-Type",
"value": "application/x-www-form-urlencoded"
}
],
"body": "To=%2B1234567890&From=%2B0987654321&Body=Hello from Jet Admin!",
"contentType": "application/x-www-form-urlencoded",
"followRedirects": true,
"sslVerify": true
}
Usage:
POST /Accounts/ACxxxx/Messages.json
Body: To=+1234567890&From=+0987654321&Body=Hello from Jet Admin!
Example 3: Custom Internal API (API Key Header)โ
{
"baseUrl": "https://api.internal.company.com/v2",
"method": "GET",
"timeout": 15,
"authType": "none",
"headers": [
{
"key": "X-API-Key",
"value": "your-api-key-here"
},
{
"key": "X-Tenant-ID",
"value": "{{ctx.tenant.id}}"
}
],
"queryParams": [
{
"key": "status",
"value": "active"
}
],
"contentType": "application/json",
"followRedirects": true,
"sslVerify": true
}
Example 4: Slack Webhook (No Auth, POST)โ
{
"baseUrl": "https://hooks.slack.com/services",
"method": "POST",
"timeout": 10,
"authType": "none",
"headers": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"body": "{\"text\":\"New order received!\",\"channel\":\"#orders\",\"username\":\"Order Bot\"}",
"contentType": "application/json",
"followRedirects": true,
"sslVerify": true
}
Example 5: Google Sheets API (OAuth2)โ
{
"baseUrl": "https://sheets.googleapis.com/v4/spreadsheets",
"method": "GET",
"timeout": 30,
"authType": "oauth2",
"oauth2": {
"clientId": "123456789-abcdefg.apps.googleusercontent.com",
"clientSecret": "GOCSPX-xxxxxxxxxxxxxxxxx",
"tokenUrl": "https://oauth2.googleapis.com/token"
},
"headers": [],
"queryParams": [
{
"key": "majorDimension",
"value": "ROWS"
}
],
"contentType": "application/json",
"followRedirects": true,
"sslVerify": true
}
Example 6: GitHub API (Bearer Token with Variables)โ
{
"baseUrl": "https://api.github.com",
"method": "GET",
"timeout": 30,
"authType": "bearer",
"bearerToken": "{{ctx.input.githubToken}}",
"headers": [
{
"key": "Accept",
"value": "application/vnd.github.v3+json"
}
],
"queryParams": [
{
"key": "per_page",
"value": "100"
}
],
"contentType": "application/json",
"followRedirects": true,
"sslVerify": true
}
Usage:
GET /repos/Jet-labs/jet-admin/issues?per_page=100
Next Stepsโ
- PostgreSQL Datasource - Connect to PostgreSQL
- Create Data Queries - Execute API calls
- Workflow Integration - Use in workflows
- Webhooks - Receive webhook data