Quickstart: build a social media post generator as a REST API
Quickstart: build a social media post generator as a REST API
Build a two-step Flow that fetches website content and generates social media posts. Attach the Flow to a Product and expose it through a REST API Surface.
Before you begin, review What are Flows?, What are Products?, and What are Surfaces?.
Before you begin
Sign in to the Runtype dashboard. Firecrawl is available through platform keys, so you do not need to add a provider API key for this quickstart.
What you build
You build a Flow that fetches article content and generates three social media posts. You then attach the Flow to a Product and call it through a REST API Surface.
Create a flow
To create the Flow, follow these steps:
- On the Flows page, click Create Flow.
- Select Start from scratch.
- Add a step with the + control.
- Select Fetch URL.
- In the Fetch selector, select Firecrawl (Web Scraping).
- In the from URL field, enter
{{website}}. When you run the Flow, enter a value forwebsite. - Add another step with the + control.
- Select Run Task.
- In the User editor, paste the following prompt:
- Set the Flow name to
Website Content to Social Media Content. - Click Create.
Flow variables use double curly braces. The {{website}} expression reads the input named website, and {{fetch_result}} reads the output from the Fetch URL step. The Fetch URL step uses fetch_result as its default output variable. If you change that output variable, update the expression in the prompt.
For more information, read Flow variables and templates.
Test the flow
To test the Flow before you create the Product, follow these steps:
- On the Flow editor, click Run flow.
- In Input Variables, enter
https://example.comas the value forwebsite. - Click Run Flow.
- Confirm that the response contains posts for Twitter, LinkedIn, and Instagram.
If the response does not contain all three posts, return to the Run Task step, edit the prompt, and run the Flow again.
Create a Product and a Surface
A Product groups related Flows and Agents. A Capability makes a Flow or Agent available on a Product. A Surface exposes the Product through an interface, such as a REST API.
To create the Product and attach your Flow, follow these steps:
- On the Products page, click New product.
- Select REST API.
- In the Name field, enter
Social Media Post Generator. - Under Add a capability to power your REST API, select Use Existing.
- Select Flows.
- Select
Website Content to Social Media Content. - Click Create REST API.
The Product includes your Flow as a Capability and a REST API Surface. The Product editor opens with the Surface panel open.
Call the endpoint
Open the Product editor and copy the endpoint URL and API key from the REST API Surface. API Surface keys use the papi_ prefix.
Send a POST request to the capability-specific endpoint. The following TypeScript example sends the website input:
Use the following cURL command to send the same request:
Replace the following placeholders in both examples:
YOUR_PRODUCT_ID: the Product ID in the endpoint URLYOUR_SURFACE_ID: the Surface ID in the endpoint URLYOUR_CAPABILITY_SLUG: the URL-safe slug for the Flow CapabilityYOUR_SURFACE_API_KEY: the full API key from the REST API Surface
The endpoint passes the request body directly to the Capability as input. Review the JSON response to confirm that the Flow returns the generated social media posts.
Next steps
Continue with these guides:
- Flow step types overview: choose steps for more advanced Flows
- What are Tools?: connect Flows and Agents to external systems
- What are Logs?: inspect execution details and failures
- Creating and managing records: add structured context to Flows
- What are Evals?: compare prompts and models with the same inputs