Skip to main content

REST API Datasource - Complete Guide

๐Ÿ”Œ Connect REST APIsโ€‹

HTTP Methods ยท Authentication ยท Headers ยท Query Params ยท Request Body


๐Ÿ“‹ Table of Contentsโ€‹


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โ€‹

FieldTypeRequiredDefaultOptionsDescription
Base URLStringโœ… Yes-Valid URLRoot URL of the REST API
MethodStringโœ… YesGETGET, POST, PUT, DELETE, PATCHHTTP method for requests

Optional Fieldsโ€‹

FieldTypeRequiredDefaultValidationDescription
TimeoutIntegerโŒ No30Min: 1Request timeout in seconds
Content TypeStringโŒ Noapplication/jsonapplication/json, application/xml, text/plainDefault 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:

MethodUse CaseHas BodyIdempotent
GETRetrieve resourcesโŒ Noโœ… Yes
POSTCreate resourcesโœ… YesโŒ No
PUTUpdate/replace resourcesโœ… Yesโœ… Yes
PATCHPartial updateโœ… YesโŒ No
DELETEDelete 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: 10 seconds
  • Standard APIs: 30 seconds
  • Slow external APIs: 60 seconds
  • File uploads: 120 seconds

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/xml
  • text/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:

FieldTypeRequiredDescription
UsernameStringโœ… YesAPI username or key
PasswordStringโœ… YesAPI 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:

FieldTypeRequiredDescription
Bearer TokenStringโœ… YesJWT, 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:

FieldTypeRequiredDescription
Client IDStringโœ… YesOAuth2 client identifier
Client SecretStringโœ… YesOAuth2 client secret
Token URLStringโœ… YesOAuth2 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:

  1. Jet Admin requests access token from token URL
  2. Token is cached for subsequent requests
  3. Token automatically refreshed when expired
  4. 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โ€‹

FieldTypeRequiredDescription
KeyStringโœ… YesHeader name
ValueStringโœ… YesHeader value

Common Headersโ€‹

HeaderValueUse Case
Acceptapplication/jsonSpecify response format
Content-Typeapplication/jsonSpecify request format
X-API-Keyyour-api-keyCustom API key header
X-Request-IDunique-idRequest tracking
User-AgentJetAdmin/1.0Custom 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โ€‹

FieldTypeRequiredDescription
KeyStringโœ… YesParameter name
ValueStringโœ… YesParameter 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โ€‹

ParameterExampleUse Case
limit?limit=100Pagination - max results
offset?offset=20Pagination - skip results
page?page=2Page number
sort?sort=created_atSort field
order?order=descSort direction
filter?filter=status:activeFilter criteria
search?search=johnSearch query
fields?fields=id,name,emailField selection

Request Bodyโ€‹

Purposeโ€‹

Send data in the request body for POST, PUT, and PATCH requests.

When to Useโ€‹

MethodBody RequiredTypical Use
POSTโœ… UsuallyCreate resource
PUTโœ… YesReplace resource
PATCHโœ… YesUpdate resource
GETโŒ NoRetrieve data
DELETEโŒ NoDelete 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โ€‹

  1. Configure REST API datasource
  2. Set method to GET (for testing)
  3. Add any required authentication
  4. Click "Test Connection"
  5. 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โ€‹

ErrorStatusCauseSolution
400 Bad Request400Invalid request formatCheck body, headers, parameters
401 Unauthorized401Authentication failedVerify API key/token
403 Forbidden403Insufficient permissionsCheck API permissions
404 Not Found404Invalid URLVerify base URL and endpoint
429 Too Many Requests429Rate limit exceededWait and retry, check rate limits
500 Internal Server Error500API server errorContact API provider
502 Bad Gateway502API gateway errorRetry later
503 Service Unavailable503API downCheck 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โ€‹