Structure
This document covers the fundamental structure of a Sling API specification file.
Root Level
At the root level, we have the following keys:
# 'name', 'description' and 'endpoints' keys are required
name: <API display name>
description: <API description>
queues: [<array of queue names>]
defaults: <endpoint configuration map>
authentication: <authentication configuration map>
endpoints:
<endpoint name>: <endpoint configuration map>Endpoint Level
The <endpoint name> identifies the API endpoint to interact with. This can be any descriptive name for the endpoint.
The <endpoint configuration map> is a map object which accepts the following keys:
Request Configuration
The <request configuration map> accepts the keys below:
Pagination Configuration
The <pagination configuration map> accepts the keys below:
Response Configuration
The <response configuration map> accepts the keys below:
Records Configuration
The <records extraction configuration map> accepts the keys below:
💡 Primary Key Priority: When using API specs in replications, the primary key defined in the replication stream configuration takes priority over the primary key defined in the API spec. If no primary key is specified in the stream, the primary key from the spec will be used.
Processor Configuration
Each processor in the processors array accepts:
Response Rules
Each rule in the rules array accepts:
Authentication Configuration
The <authentication configuration map> accepts the keys below:
Iteration Configuration
The <iteration configuration map> accepts the keys below:
Endpoint Dependencies
The depends_on field explicitly declares that an endpoint depends on other endpoints completing first. This is useful for controlling execution order.
📝 Note: When using queues with
iterate.over, Sling automatically infers dependencies. Thedepends_onfield is optional but can make dependencies explicit.
Stream Overrides
The overrides field allows you to configure how the endpoint's data is processed when writing to a destination. This is used during replication to control stream-specific behavior.
Basic Overrides
Control the replication mode for specific endpoints:
Available modes:
full-refresh: Replace all data (truncate and load)incremental: Append new records onlysnapshot: Create versioned snapshotsbackfill: Historical data loading
Hooks Override
Add post-processing hooks for specific endpoints. This is powerful for merge operations, data cleanup, or custom transformations:
Hook Types Available:
check: Validate conditions before proceedingquery: Execute SQL operations (merge, drop, etc.)log: Log messages for debugginghttp: Call external APIscommand: Run shell commands
See Hooks documentation for complete details.
💡 Tip: Overrides are most useful when extracting large datasets that need special handling during the write phase, or when implementing complex merge/upsert logic.
State vs. Sync
Understanding the difference between state and sync:
State Variables
The state field defines variables available during endpoint execution. State is:
Temporary: Exists only during current run
Per-endpoint: Each endpoint has its own state
Per-iteration: Each iteration (if using
iterate) gets its own state copy
Sync Variables
The sync field lists which state variables should persist between runs. This enables incremental data loading:
Key Differences:
Scope
Current run only
Persisted between runs
Purpose
Runtime variables
Incremental tracking
Declaration
state: {key: value}
sync: [key]
Access
state.key
sync.key (on load) → state.key (during run)
Use Case
Configuration, calculations
Timestamps, cursors, offsets
Context Variables
Context variables are read-only runtime values passed from the replication configuration to the API spec. They enable endpoints to support both backfill and incremental modes with a single configuration.
Available Context Variables:
context.mode
string
Replication mode
Replication config mode field
context.limit
integer
Maximum records to fetch
Replication config source_options.limit
context.range_start
string
Backfill range start
Replication config source_options.range (first value)
context.range_end
string
Backfill range end
Replication config source_options.range (second value)
Context vs. State vs. Sync:
Source
Replication config
API spec
Persisted storage
Scope
Current run
Current run
Between runs
Modifiable
No (read-only)
Yes
Yes (via state)
Common Pattern: Backfill with Incremental Fallback
This pattern supports backfill (with range), incremental (with sync state), and first run (with default):
Replication Configs:
Other Common Uses:
💡 Best Practice: Always use
coalesce()with context variables to provide fallback values for when they're not set.
Using Inputs
Inputs are custom configuration values passed from the connection definition to the API spec. Unlike secrets (which are for credentials), inputs are for non-sensitive options like field mappings, account IDs, or feature flags. Inputs are accessed via {inputs.var_name}, similar to secrets and env.
Defining inputs in env.yaml:
Accessing inputs in your API spec:
When to use inputs vs. secrets:
Use Case
Use secrets
Use inputs
API keys, tokens, passwords
✅
Client IDs/secrets
✅
Account IDs (non-sensitive)
✅
Field name mappings
✅
Feature flags
✅
Custom configuration options
✅
📝 Note: Inputs are defined by the API spec author. Check the specific API connector documentation to see what inputs are available.
Queues
Queues allow you to pass data from one endpoint to another in a multi-step workflow:
For detailed information on queues, see Queues.
Sequence of Calls
A sequence is an ordered array of API calls that can be executed in workflows, authentication processes, and lifecycle hooks. Sequences are perfect for multi-step operations like async job workflows, custom authentication flows, or complex setup/teardown processes.
For detailed information on sequences, see Sequences: Setup and Teardown.
Component Relationships
The following diagram shows how the major components relate to each other:
Basic Example
Here's a minimal example showing the essential components:
API Specification
Here we have the definitions for the accepted keys.
name
The display name of the API specification.
description
Brief description of what the API does.
queues
Array of queue names for passing data between endpoints.
defaults
Default endpoint configuration applied to all endpoints.
authentication
Authentication configuration for the API. See Authentication for details.
endpoints.<key>
Named endpoints that define API interactions.
dynamic_endpoints
Array of endpoint configurations for dynamic endpoint generation. See Dynamic Endpoints for details.
endpoints.<key>.name
or defaults.name
The endpoint name (defaults to the key).
endpoints.<key>.description
or defaults.description
Description of what the endpoint does.
endpoints.<key>.docs
or defaults.docs
URL to endpoint documentation.
endpoints.<key>.disabled
or defaults.disabled
Whether the endpoint is disabled (default: false).
endpoints.<key>.state
or defaults.state
Map of state variables available to the endpoint. See State vs. Sync section above.
endpoints.<key>.sync
or defaults.sync
Array of state variable names to persist between runs. See State vs. Sync section above.
endpoints.<key>.request
or defaults.request
HTTP request configuration. See Requests for details.
endpoints.<key>.pagination
or defaults.pagination
Pagination configuration. See Pagination for details.
endpoints.<key>.response
or defaults.response
Response processing configuration. See Response Processing for details.
endpoints.<key>.iterate
or defaults.iterate
Iteration configuration for looping over data. See Iteration for details.
endpoints.<key>.setup
or defaults.setup
Array of calls to execute before the main request. See Sequences for details.
endpoints.<key>.teardown
or defaults.teardown
Array of calls to execute after the main request. See Sequences for details.
endpoints.<key>.depends_on
or defaults.depends_on
Array of endpoint names this endpoint depends on. See Endpoint Dependencies section above.
endpoints.<key>.overrides
or defaults.overrides
Stream processing overrides for destination writing. See Stream Overrides section above.
💡 Tip: Start with the basic example and gradually add complexity as needed. Use the defaults section to avoid repetition across endpoints.
Last updated
Was this helpful?