Flowtest Samples
Below are quick examples showing common Flowtest features. Copy the snippets and modify them to suit your API.
Getting Data
{
"title": "Simple GET",
"steps": [
{ "title": "Fetch", "method": "GET", "url": "https://example.org" }
]
}
HTTP Headers
{
"title": "Headers Demo",
"default_headers": { "User-Agent": "Flowtest" },
"steps": [
{
"title": "News",
"method": "GET",
"url": "https://example.org/news",
"headers": { "Accept-Language": "en-US" }
}
]
}
Query Parameters
{
"title": "Query Params",
"steps": [
{
"title": "Search",
"method": "GET",
"url": "https://example.org/news",
"query": {
"order": "newest",
"search": "something to search",
"count": "100"
}
}
]
}
Posting JSON
{
"title": "Post JSON",
"steps": [
{
"title": "Create",
"method": "POST",
"url": "https://example.org/api/tests",
"body": "{\"id\": \"456\", \"evaluate\": true}",
"assert": { "response.status": "201" }
}
]
}
Passing Data
{
"title": "Chained Requests",
"steps": [
{
"title": "Create order",
"method": "POST",
"url": "https://sample.org/orders",
"assign": { "order_id": "response.bodyJson.id" },
"assert": { "response.status": "201" }
},
{
"title": "Get order",
"method": "GET",
"url": "https://sample.org/orders/{{ order_id }}",
"assert": { "response.status": "200" }
}
]
}
Retrying and Delays
{
"title": "Retry Example",
"steps": [
{
"title": "Check job",
"method": "GET",
"url": "https://api.example.org/job/123",
"sleep": "5s",
"retry": { "max_attempts": 5, "sleep": "500ms", "assert": { "response.status": "200" } }
}
]
}
Deferred Cleanup
{
"title": "Deferred Cleanup",
"steps": [
{
"title": "Create temp",
"method": "POST",
"url": "https://api.example.org/temp",
"assign": { "id": "response.bodyJson.id" },
"assert": { "response.status": "201" }
},
{
"title": "Delete temp",
"method": "DELETE",
"url": "https://api.example.org/temp/{{ id }}",
"defer": true,
"assert": { "response.status": "200" }
},
{
"title": "Do work",
"method": "GET",
"url": "https://api.example.org/temp/{{ id }}",
"assert": { "response.status": "200" }
}
]
}
Testing Responses
{
"title": "Assertions",
"steps": [
{
"title": "Check status and header",
"method": "GET",
"url": "https://example.org/index.html",
"assert": {
"response.status": "200",
"response.headers.Content-Type": "contains:text/html"
}
},
{
"title": "Check JSON body",
"method": "GET",
"url": "https://example.org/api/user",
"assert": { "response.body.json.name": "Alice" }
}
]
}