> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.muchau.com.br/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.muchau.com.br/_mcp/server.

# Criar um flow

POST https://dev.muchau.com.br/api/flows/
Content-Type: application/json

Cria um novo WhatsApp Flow.

Reference: https://docs.muchau.com.br/api/reference/flows/criar-um-flow

## Authentication

- `Authorization` header (bearer token, required) — API Key in the format `mk_live_<43-chars>`. Obtain from the Dashboard or `POST /auth/api-keys`.

## Request

### Body (application/json)

This endpoint expects an object.

- `numberId` (string, required) — WhatsApp Number ID to create the flow under
- `name` (string, required) — Display name for the flow
- `categories` (list of string, required) — Flow categories (e.g., SIGN_UP, SIGN_IN, CONTACT_US, OTHER)
- `publicKey` (string, required) — PEM-encoded RSA 2048 public key for flow data exchange encryption
- `endpointUrl` (string, required) — HTTPS endpoint URL where data exchange requests will be forwarded

## Response

### 201

Default Response

- `id` (string, required) — Unique identifier of the flow in the Muchaw platform
- `developerId` (string, required) — ID of the developer who owns this flow
- `wabaId` (string, required) — WhatsApp Business Account ID this flow belongs to
- `metaFlowId` (string, required) — Flow ID assigned by Meta
- `name` (string, required) — Flow name
- `status` (enum, required) — Current lifecycle status of the flow
  - Allowed values: `DRAFT`, `PUBLISHED`, `DEPRECATED`
- `categories` (list of string, required) — Flow categories
- `jsonVersion` (string, required, nullable) — Version of the flow JSON spec
- `endpointUrl` (string, required, nullable) — HTTPS endpoint URL for data exchange
- `publicKeyConfigured` (boolean, required) — Whether a public key is configured for this flow
- `createdAt` (string, required) — ISO 8601 datetime when the flow was created
- `updatedAt` (string, required) — ISO 8601 datetime when the flow was last updated

## Errors

### 400 Bad Request Error

Default Response

- `error` (ApiFlowsPostResponsesContentApplicationJsonSchemaError, required)

### 401 Unauthorized Error

Default Response

- `error` (ApiFlowsPostResponsesContentApplicationJsonSchemaError, required)

## Types

### ApiFlowsPostResponsesContentApplicationJsonSchemaError

- `code` (string, required) — Machine-readable error code (e.g., UNAUTHORIZED, NOT_FOUND, VALIDATION_ERROR)
- `message` (string, required) — Human-readable error description
- `status` (integer, required) — HTTP status code
- `meta` (ApiFlowsPostResponsesContentApplicationJsonSchemaErrorMeta, optional)
- `error_shield` (ApiFlowsPostResponsesContentApplicationJsonSchemaErrorErrorShield, optional)

### ApiFlowsPostResponsesContentApplicationJsonSchemaErrorMeta

- `meta_code` (integer, required)
- `meta_message` (string, required)
- `meta_subcode` (integer, required, nullable)
- `type` (string, required, nullable)
- `fbtrace_id` (string, required, nullable)
- `error_data` (any, optional)

### ApiFlowsPostResponsesContentApplicationJsonSchemaErrorErrorShield

- ApiFlowsPostResponsesContentApplicationJsonSchemaErrorErrorShield0
- ApiFlowsPostResponsesContentApplicationJsonSchemaErrorErrorShield1

### ApiFlowsPostResponsesContentApplicationJsonSchemaErrorErrorShield0

- `matched` (boolean, required)
- `entry_id` (string, required)
- `category` (enum, required)
  - Allowed values: `template`, `number`, `messaging`, `flow`, `permission`, `rate_limit`, `other`
- `severity` (enum, required)
  - Allowed values: `informational`, `recoverable`, `blocking`, `critical`
- `actor` (enum, required)
  - Allowed values: `developer`, `end_client`, `muchau`
- `human_message` (ApiFlowsPostResponsesContentApplicationJsonSchemaErrorErrorShieldOneOf0HumanMessage, required)
- `action` (ApiFlowsPostResponsesContentApplicationJsonSchemaErrorErrorShieldOneOf0Action, required)
- `action_url` (string, required, nullable)
- `docs_url` (string, required)
- `copy_text` (ApiFlowsPostResponsesContentApplicationJsonSchemaErrorErrorShieldOneOf0CopyText, required)
- `version` (integer, required)
- `last_updated` (string, required)

### ApiFlowsPostResponsesContentApplicationJsonSchemaErrorErrorShield1

- `matched` (boolean, required)
- `note` (ApiFlowsPostResponsesContentApplicationJsonSchemaErrorErrorShieldOneOf1Note, required)

### ApiFlowsPostResponsesContentApplicationJsonSchemaErrorErrorShieldOneOf0HumanMessage

- `pt` (string, required)
- `en` (string, required)

### ApiFlowsPostResponsesContentApplicationJsonSchemaErrorErrorShieldOneOf0Action

- `pt` (string, required)
- `en` (string, required)

### ApiFlowsPostResponsesContentApplicationJsonSchemaErrorErrorShieldOneOf0CopyText

- `pt` (string, required, nullable)
- `en` (string, required, nullable)

### ApiFlowsPostResponsesContentApplicationJsonSchemaErrorErrorShieldOneOf1Note

- `pt` (string, required)
- `en` (string, required)

## Examples

**Request**

```json
{
  "numberId": "whatsapp-number-12345",
  "name": "Customer Support Flow",
  "categories": [
    "CONTACT_US"
  ],
  "publicKey": "-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAv1X9Zb1k5v+2Q9J6X9qF\n3v1Zx9Q+7v1X9Zb1k5v+2Q9J6X9qF3v1Zx9Q+7v1X9Zb1k5v+2Q9J6X9qF3v1Zx9\nQ+7v1X9Zb1k5v+2Q9J6X9qF3v1Zx9Q+7v1X9Zb1k5v+",
  "endpointUrl": "https://api.example.com/flows/customer-support"
}
```

**Response**

```json
{
  "id": "flow-98765",
  "developerId": "dev-1234567890abcdef",
  "wabaId": "waba-54321",
  "metaFlowId": "meta-flow-112233",
  "name": "Customer Support Flow",
  "status": "DRAFT",
  "categories": [
    "CONTACT_US"
  ],
  "jsonVersion": "1.0.0",
  "endpointUrl": "https://api.example.com/flows/customer-support",
  "publicKeyConfigured": true,
  "createdAt": "2024-06-01T10:15:30Z",
  "updatedAt": "2024-06-01T10:15:30Z"
}
```

**SDK Code**

```python
import requests

url = "https://dev.muchau.com.br/api/flows/"

payload = {
    "numberId": "whatsapp-number-12345",
    "name": "Customer Support Flow",
    "categories": ["CONTACT_US"],
    "publicKey": "-----BEGIN PUBLIC KEY-----
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAv1X9Zb1k5v+2Q9J6X9qF
3v1Zx9Q+7v1X9Zb1k5v+2Q9J6X9qF3v1Zx9Q+7v1X9Zb1k5v+2Q9J6X9qF3v1Zx9
Q+7v1X9Zb1k5v+2Q9J6X9qF3v1Zx9Q+7v1X9Zb1k5v+",
    "endpointUrl": "https://api.example.com/flows/customer-support"
}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```javascript
const url = 'https://dev.muchau.com.br/api/flows/';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"numberId":"whatsapp-number-12345","name":"Customer Support Flow","categories":["CONTACT_US"],"publicKey":"-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAv1X9Zb1k5v+2Q9J6X9qF\n3v1Zx9Q+7v1X9Zb1k5v+2Q9J6X9qF3v1Zx9Q+7v1X9Zb1k5v+2Q9J6X9qF3v1Zx9\nQ+7v1X9Zb1k5v+2Q9J6X9qF3v1Zx9Q+7v1X9Zb1k5v+","endpointUrl":"https://api.example.com/flows/customer-support"}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://dev.muchau.com.br/api/flows/"

	payload := strings.NewReader("{\n  \"numberId\": \"whatsapp-number-12345\",\n  \"name\": \"Customer Support Flow\",\n  \"categories\": [\n    \"CONTACT_US\"\n  ],\n  \"publicKey\": \"-----BEGIN PUBLIC KEY-----\\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAv1X9Zb1k5v+2Q9J6X9qF\\n3v1Zx9Q+7v1X9Zb1k5v+2Q9J6X9qF3v1Zx9Q+7v1X9Zb1k5v+2Q9J6X9qF3v1Zx9\\nQ+7v1X9Zb1k5v+2Q9J6X9qF3v1Zx9Q+7v1X9Zb1k5v+\",\n  \"endpointUrl\": \"https://api.example.com/flows/customer-support\"\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Authorization", "Bearer <token>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby
require 'uri'
require 'net/http'

url = URI("https://dev.muchau.com.br/api/flows/")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"numberId\": \"whatsapp-number-12345\",\n  \"name\": \"Customer Support Flow\",\n  \"categories\": [\n    \"CONTACT_US\"\n  ],\n  \"publicKey\": \"-----BEGIN PUBLIC KEY-----\\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAv1X9Zb1k5v+2Q9J6X9qF\\n3v1Zx9Q+7v1X9Zb1k5v+2Q9J6X9qF3v1Zx9Q+7v1X9Zb1k5v+2Q9J6X9qF3v1Zx9\\nQ+7v1X9Zb1k5v+2Q9J6X9qF3v1Zx9Q+7v1X9Zb1k5v+\",\n  \"endpointUrl\": \"https://api.example.com/flows/customer-support\"\n}"

response = http.request(request)
puts response.read_body
```

```java
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://dev.muchau.com.br/api/flows/")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"numberId\": \"whatsapp-number-12345\",\n  \"name\": \"Customer Support Flow\",\n  \"categories\": [\n    \"CONTACT_US\"\n  ],\n  \"publicKey\": \"-----BEGIN PUBLIC KEY-----\\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAv1X9Zb1k5v+2Q9J6X9qF\\n3v1Zx9Q+7v1X9Zb1k5v+2Q9J6X9qF3v1Zx9Q+7v1X9Zb1k5v+2Q9J6X9qF3v1Zx9\\nQ+7v1X9Zb1k5v+2Q9J6X9qF3v1Zx9Q+7v1X9Zb1k5v+\",\n  \"endpointUrl\": \"https://api.example.com/flows/customer-support\"\n}")
  .asString();
```

```php
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://dev.muchau.com.br/api/flows/', [
  'body' => '{
  "numberId": "whatsapp-number-12345",
  "name": "Customer Support Flow",
  "categories": [
    "CONTACT_US"
  ],
  "publicKey": "-----BEGIN PUBLIC KEY-----\\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAv1X9Zb1k5v+2Q9J6X9qF\\n3v1Zx9Q+7v1X9Zb1k5v+2Q9J6X9qF3v1Zx9Q+7v1X9Zb1k5v+2Q9J6X9qF3v1Zx9\\nQ+7v1X9Zb1k5v+2Q9J6X9qF3v1Zx9Q+7v1X9Zb1k5v+",
  "endpointUrl": "https://api.example.com/flows/customer-support"
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

```csharp
using RestSharp;

var client = new RestClient("https://dev.muchau.com.br/api/flows/");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"numberId\": \"whatsapp-number-12345\",\n  \"name\": \"Customer Support Flow\",\n  \"categories\": [\n    \"CONTACT_US\"\n  ],\n  \"publicKey\": \"-----BEGIN PUBLIC KEY-----\\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAv1X9Zb1k5v+2Q9J6X9qF\\n3v1Zx9Q+7v1X9Zb1k5v+2Q9J6X9qF3v1Zx9Q+7v1X9Zb1k5v+2Q9J6X9qF3v1Zx9\\nQ+7v1X9Zb1k5v+2Q9J6X9qF3v1Zx9Q+7v1X9Zb1k5v+\",\n  \"endpointUrl\": \"https://api.example.com/flows/customer-support\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [
  "numberId": "whatsapp-number-12345",
  "name": "Customer Support Flow",
  "categories": ["CONTACT_US"],
  "publicKey": "-----BEGIN PUBLIC KEY-----
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAv1X9Zb1k5v+2Q9J6X9qF
3v1Zx9Q+7v1X9Zb1k5v+2Q9J6X9qF3v1Zx9Q+7v1X9Zb1k5v+2Q9J6X9qF3v1Zx9
Q+7v1X9Zb1k5v+2Q9J6X9qF3v1Zx9Q+7v1X9Zb1k5v+",
  "endpointUrl": "https://api.example.com/flows/customer-support"
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://dev.muchau.com.br/api/flows/")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```