Sim Studio

Response

Send a structured response back to API calls

The Response block is the final component in API-enabled workflows that transforms your workflow's variables into a structured HTTP response. This block serves as the endpoint that returns data, status codes, and headers back to API callers.

Response blocks are terminal blocks - they mark the end of a workflow execution and cannot have further connections.

Overview

The Response block serves as the final output mechanism for API workflows, enabling you to:

Return structured data: Transform workflow variables into JSON responses

Set HTTP status codes: Control the response status (200, 400, 500, etc.)

Configure headers: Add custom HTTP headers to the response

Reference variables: Use workflow variables dynamically in the response

Configuration Options

Response Data

The response data is the main content that will be sent back to the API caller. This should be formatted as JSON and can include:

  • Static values
  • Dynamic references to workflow variables using the <variable.name> syntax
  • Nested objects and arrays
  • Any valid JSON structure

Status Code

Set the HTTP status code for the response. Common status codes include:

  • 200: OK - Standard success response
  • 201: Created - Resource successfully created
  • 204: No Content - Success with no response body

Default status code is 200 if not specified.

Response Headers

Configure additional HTTP headers to include in the response.

Headers are configured as key-value pairs:

KeyValue
Content-Typeapplication/json
Cache-Controlno-cache
X-API-Version1.0

Inputs and Outputs

  • data (JSON, optional): The JSON data to send in the response body

  • status (number, optional): HTTP status code (default: 200)

  • headers (JSON, optional): Additional response headers

Variable References

Use the <variable.name> syntax to dynamically insert workflow variables into your response:

{
  "user": {
    "id": "<variable.userId>",
    "name": "<variable.userName>",
    "email": "<variable.userEmail>"
  },
  "query": "<variable.searchQuery>",
  "results": "<variable.searchResults>",
  "totalFound": "<variable.resultCount>",
  "processingTime": "<variable.executionTime>ms"
}

Variable names are case-sensitive and must match exactly with the variables available in your workflow.

Example Usage

Here's an example of how a Response block might be configured for a user search API:

data: |
  {
    "success": true,
    "data": {
      "users": "<variable.searchResults>",
      "pagination": {
        "page": "<variable.currentPage>",
        "limit": "<variable.pageSize>",
        "total": "<variable.totalUsers>"
      }
    },
    "query": {
      "searchTerm": "<variable.searchTerm>",
      "filters": "<variable.appliedFilters>"
    },
    "timestamp": "<variable.timestamp>"
  }
status: 200
headers:
  - key: X-Total-Count
    value: <variable.totalUsers>
  - key: Cache-Control
    value: public, max-age=300

Best Practices

  • Use meaningful status codes: Choose appropriate HTTP status codes that accurately reflect the outcome of the workflow
  • Structure your responses consistently: Maintain a consistent JSON structure across all your API endpoints for better developer experience
  • Include relevant metadata: Add timestamps and version information to help with debugging and monitoring
  • Handle errors gracefully: Use conditional logic in your workflow to set appropriate error responses with descriptive messages
  • Validate variable references: Ensure all referenced variables exist and contain the expected data types before the Response block executes