Laminar
  • Laminar
  • Platform
    • Overview
    • Getting Started
    • Advanced
      • Configurations
      • HTTP Request Batching
      • Workflow Exit Points
      • Invoke Secondary Workflows
      • Managing Notifications
    • Best Practices
    • Keywords
      • lam.resolveThenExecute
      • lam.exit
      • lam.execute
      • lam.asyncExecute
      • lam.httpRequest
      • lam.httpRequests
  • Concepts
    • Workflows
      • Global Workflow Object
    • Flows
      • Flow Types
        • HTTP Request
        • Data Transformations
      • Flow Runs
      • Supported Languages
    • API Key
    • Configurations
    • API
      • Reference
        • Workspaces
          • Issues
          • Users
          • Invitations
            • Decline
            • Accept
            • Received
            • Created
          • Workflows
          • Flows
          • Auth credentials
          • Api keys
          • Api descriptions
        • Workflow
          • Execute
            • External
          • Flows
          • Executions
        • Users
        • Flows
          • Runs
          • Versions
          • Stats
          • Recent runs
          • Read
        • Configurations
          • Properties
          • Flow credentials
          • Workspace
        • Auth credentials
        • Api descriptions
        • Api keys
        • Transform
          • Test
        • Lami
          • Public
          • Direct
        • Auth
          • Signin
          • Register
          • Refresh
          • Me
          • Users
            • Password
    • Changelog
  • External Links
    • Book a Demo
    • Playground
    • Sign In
  • Specification
Powered by GitBook
On this page
  • Basic Structure
  • Optional Attributes
  • Path Parameters
  • Query Parameters
  • Headers
  • Body
  • Multiple Requests

Was this helpful?

  1. Concepts
  2. Flows
  3. Flow Types

HTTP Request

Learn about writing HTTP requests in Laminar Editor

Basic Structure

In Laminar, to codify an HTTP request, you must update your flow program to return an object with the following format:

{
  "lam.httpRequest": {
    "method": "POST", // (or "GET", "PUT", "DELETE")
    "url": "https://api.example.com/endpoint",
    "pathParams": { /* optional */ },
    "queryParams": { /* optional */ },
    "headers": { /* optional */ },
    "body": { /* optional */ }
  }
}

Examples

  1. Let's start with a basic GET request to fetch users:

(payload) => {
  const { input } = payload;
  
  return {
    "lam.httpRequest": {
      "method": "GET",
      "url": "https://api.example.com/users"
    }
  }
}
  1. Now, let's create a user with a POST request:

(payload) => {
  const { input } = payload;
  
  return {
    "lam.httpRequest": {
      "method": "POST",
      "url": "https://api.example.com/products",
      "body": {
        "name": "John Doe",
        "email": "john@example.com"
      }
    }
  }
}

Optional Attributes

Now let's explore each optional attribute and how to use them effectively.

Path Parameters

Path parameters are used to replace dynamic segments in your URL path.

Example:

(payload) => {
  const { input } = payload;
  
  return {
    "lam.httpRequest": {
      "method": "GET",
      "url": "https://api.example.com/users/{userId}",
      "pathParams": {
        "userId": "12345"
      }
    }
  }
}

This will resolve to a request to https://api.example.com/users/12345.

Query Parameters

Query parameters add a query string to your URL.

Example:

(payload) => {
  const { input } = payload;
  
  return {
    "lam.httpRequest": {
      "method": "GET",
      "url": "https://api.example.com/users",
      "queryParams": {
        "page": 1,
        "limit": 10,
        "sort": "name"
      }
    }
  }
}

This will resolve to a request to https://api.example.com/users?page=1&limit=10&sort=name

Headers

Headers allow you to send additional information with your request.

Example:

(payload) => {
  const { input } = payload;
  
  return {
    "lam.httpRequest": {
      "method": "GET",
      "url": "https://api.example.com/users",
      "headers": {
        "Authorization": "Bearer token123",
        "Content-Type": "application/json",
        "Accept-Language": "en-US"
      }
    }
  }
}

Body

The body contains data sent with the request. It's typically used with POST, PUT, and PATCH methods.

Example:

(payload) => {
  const { input } = payload;
  
  return {
    "lam.httpRequest": {
      "method": "POST",
      "url": "https://api.example.com/users",
      "headers": {
        "Content-Type": "application/json"
      },
      "body": {
        "name": "Jane Smith",
        "email": "jane@example.com",
        "role": "admin"
      }
    }
  }
}

Multiple Requests

You can make your batch requests more powerful by using dynamic path parameters. This is especially useful when working with lists of IDs:

(payload) => {
  const { input } = payload;
  
  return userIds.map(userId => ({
  "lam.httpRequest": {
    "method": "GET",
    "url": "https://api.example.com/users/{userId}",
    "pathParams": {
      "userId": userId
    }
  }
}));

PreviousFlow TypesNextData Transformations

Last updated 1 month ago

Was this helpful?

Laminar also supports sending multiple HTTP requests in a single operation. This is useful for batch processing or when you need to perform several related actions at once. See .

HTTP Request Batching