Rest API Path Variables
In BuildShip, you can define dynamic parts of the path using named parameters, often called wildcards or path variables. This allows you to create flexible and reusable API endpoints.
Path variables are only available for the Rest API type triggers. Learn more
Setting Up Path Variables
To set up a path variable in the REST API trigger configuration, specify the Path and Method. For dynamic paths, use a
named parameter by prefixing it with a colon (:
).
Example Configuration
- Path:
/api/call/:id
- Method:
GET
(orPOST
,PUT
,DELETE
depending on your requirement)
With this configuration, if a request is made to a URL like https://myproject.buildship.run/api/call/123
, the workflow
associated with this path will be triggered. The variable part, 123
, is captured by :id
.
Accessing Path Variables
We can access the path variable while setting up the workflow inputs in the trigger configuration.
You can access the path variable using the params
object. To extract the id
from the path, you can use the following expression:
expression editor:
Remix this workflow to see how it works: link (opens in a new tab)
Wildcard Use Cases
Path variables are useful when you want to create a single workflow that can handle multiple requests based on the path.
Multiple Path Variables
We could have multiple path variables in a single path. For example, /users/:userId/posts/:postId
. In this case, the workflow will be triggered when a request is made to a URL like https://myproject.buildship.run/users/123/posts/456
.
Here's how you can access multiple path variables in the trigger configuration:
Catch-all wildcard (*)
You can also use a catch-all wildcard (*
) to match any path. For example, /api/*
. This will match any path starting with /api/
.
Need Help?
- 💬Join BuildShip Community
An active and large community of no-code / low-code builders. Ask questions, share feedback, showcase your project and connect with other BuildShip enthusiasts.
- 🙋Hire a BuildShip Expert
Need personalized help to build your product fast? Browse and hire from a range of independent freelancers, agencies and builders - all well versed with BuildShip.
- 🛟Send a Support Request
Got a specific question on your workflows / project or want to report a bug? Send a us a request using the "Support" button directly from your BuildShip Dashboard.
- ⭐️Feature Request
Something missing in BuildShip for you? Share on the #FeatureRequest channel on Discord. Also browse and cast your votes on other feature requests.