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
- 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.
- Optional: read What are Flows?, What are Products?, and What are Surfaces?.
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:
- Next to the model selector, click Advanced settings. The Advanced Settings panel opens.
- Under Response Format, turn off Use model default. The format changes to JSON, so the endpoint returns the posts as a JSON object instead of a text string.
- 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:
- In the Flow editor, click Run flow. The Run Flow panel opens.
- 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
The API Surface starts in draft mode and has no API key. To activate the Surface and create a key, follow these steps:
- In the Product editor, open the Overview tab.
- Set the status to Active. The Surface now accepts requests.
- Open the Keys tab.
- Click Generate Key.
- In Key Type, select Test.
- Click Generate Key.
- Copy the generated key.
- Open the Endpoints tab and copy the endpoint URL.
A Test key allows 50 requests per UTC day. For real traffic, generate a Production key. A Production key has no daily cap, but the dialog shows it only once, so copy or download it before you close the dialog. For more information, read Authenticating with product API keys.
To test the endpoint in the dashboard before you write code, follow these steps:
- On the Endpoints tab, click the
Website Content to Social Media Contentendpoint. - In Request Body, enter
{"website": "https://example.com"}. - Click Run. The response appears below the request body.
To browse and test every endpoint on the Surface, click Interactive API docs.
To call the endpoint from your code, send a POST request to the endpoint URL. 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 URLpapi_YOUR_PRODUCT_KEY: the full API key that you generated on the Keys tab
The last part of the URL is the endpoint slug. Runtype derives it from the Flow name, so the slug for this quickstart is website-content-to-social-media-content unless you changed it. If your slug is different, use the URL from the Endpoints tab.
The endpoint passes the request body to the Flow as input. By default, the response contains only the output of the last step. A successful response looks like the following example:
To add execution metadata to the response or return a different step, change Response Shape or Return Step on the Overview tab. For more information, read Setting up an API surface.
To receive the output as Server-Sent Events while the Flow runs, add ?stream=true to the endpoint URL. For the event format, read Calling your API endpoints.
Troubleshoot
The following list describes common errors and how to fix them:
401withAPI surface is not active: On the Overview tab, set the status to Active.401with any other message: Confirm that theAuthorizationheader contains the full key, including thepapi_prefix.429withTest Key Limit Exceeded: The Test key used its 50 requests for the day. Wait until midnight UTC, or generate a Production key.- The response is one string instead of a JSON object: Set Response Format to JSON in the Run Task step, then call the endpoint again.
Next steps
Continue with these guides:
- Calling your API endpoints: send requests, stream responses, and handle errors
- Setting up an API surface: configure authentication, status, and the response shape
- Authenticating with product API keys: manage Test and Production keys
- Auto-generated OpenAPI spec: generate clients from the Surface specification
- Quickstart: from Agent to chat widget: expose an Agent through a chat Surface
- 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