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

# Criar cliente

POST https://wbudget.app/api/v1/api/v1/clients
Content-Type: application/json

Cria um cliente.

**Autenticação:** Bearer Token da API WBudget. O acesso aos dados respeita as permissões do usuário.

### Corpo da requisição

| Campo         | Tipo   | Obrigatório | Descrição                              |
| ------------- | ------ | ----------- | -------------------------------------- |
| `name`        | string | Sim         | Nome do cliente.                       |
| `email`       | string | Não         | E-mail válido.                         |
| `phone`       | string | Não         | Telefone com código do país e DDD.     |
| `national_id` | string | Não         | Documento fiscal; mantenha como texto. |
| `sponsor`     | string | Não         | Nome do contato principal.             |

### Exemplo de JSON enviado

```json
{
  "name": "Empresa Exemplo",
  "email": "contato@example.com",
  "phone": "+5511999990000",
  "national_id": "11222333000181",
  "sponsor": "Ana Silva"
}
```

### Resposta

HTTP **201**. Os exemplos usam dados fictícios e mostram os campos principais; outros campos podem acompanhar a resposta. Campos sem valor podem ser nulos.

Campos principais de `data`:

| Campo  | Tipo    | Descrição             |
| ------ | ------- | --------------------- |
| `id`   | integer | ID do cliente criado. |
| `name` | string  | Nome do cliente.      |

```json
{
  "data": {
    "id": 101,
    "name": "Empresa Exemplo"
  }
}
```

### Erros específicos

| HTTP | Código              | Situação                    |
| ---- | ------------------- | --------------------------- |
| 422  | `VALIDATION_FAILED` | The name field is required. |

Consulte a introdução da collection para o formato de erros e a configuração das variáveis.

Reference: https://developers.wbudget.app/w-budget/clientes/criar-cliente

## Authentication

- `Authorization` header (bearer token, required) — Bearer authentication of the form `Bearer <token>`, where token is your auth token.

## Request

### Body (application/json)

This endpoint expects an object.

- `name` (string, required)
- `email` (string, required)
- `phone` (string, required)
- `national_id` (string, required)
- `sponsor` (string, required)

## Response

### 201

Created

- `data` (object, required)
  - `id` (integer, required)
  - `name` (string, required)

## Errors

### 422 Unprocessable Entity Error

Unprocessable Entity

- `error` (object, required)
  - `message` (string, required)
  - `code` (string, required)
  - `validation_errors` (object, required)
    - `name` (list of string, required)

## Examples

**Request**

```json
{
  "name": "Empresa Exemplo",
  "email": "contato@example.com",
  "phone": "+5511999990000",
  "national_id": "11222333000181",
  "sponsor": "Ana Silva"
}
```

**Response**

```json
{
  "data": {
    "id": 101,
    "name": "Empresa Exemplo"
  }
}
```

**SDK Code**

```python Clientes_Criar cliente_example
import requests

url = "https://wbudget.app/api/v1/api/v1/clients"

payload = {
    "name": "Empresa Exemplo",
    "email": "contato@example.com",
    "phone": "+5511999990000",
    "national_id": "11222333000181",
    "sponsor": "Ana Silva"
}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript Clientes_Criar cliente_example
const url = 'https://wbudget.app/api/v1/api/v1/clients';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"name":"Empresa Exemplo","email":"contato@example.com","phone":"+5511999990000","national_id":"11222333000181","sponsor":"Ana Silva"}'
};

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

```go Clientes_Criar cliente_example
package main

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

func main() {

	url := "https://wbudget.app/api/v1/api/v1/clients"

	payload := strings.NewReader("{\n  \"name\": \"Empresa Exemplo\",\n  \"email\": \"contato@example.com\",\n  \"phone\": \"+5511999990000\",\n  \"national_id\": \"11222333000181\",\n  \"sponsor\": \"Ana Silva\"\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 Clientes_Criar cliente_example
require 'uri'
require 'net/http'

url = URI("https://wbudget.app/api/v1/api/v1/clients")

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  \"name\": \"Empresa Exemplo\",\n  \"email\": \"contato@example.com\",\n  \"phone\": \"+5511999990000\",\n  \"national_id\": \"11222333000181\",\n  \"sponsor\": \"Ana Silva\"\n}"

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

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

HttpResponse<String> response = Unirest.post("https://wbudget.app/api/v1/api/v1/clients")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"name\": \"Empresa Exemplo\",\n  \"email\": \"contato@example.com\",\n  \"phone\": \"+5511999990000\",\n  \"national_id\": \"11222333000181\",\n  \"sponsor\": \"Ana Silva\"\n}")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://wbudget.app/api/v1/api/v1/clients', [
  'body' => '{
  "name": "Empresa Exemplo",
  "email": "contato@example.com",
  "phone": "+5511999990000",
  "national_id": "11222333000181",
  "sponsor": "Ana Silva"
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp Clientes_Criar cliente_example
using RestSharp;

var client = new RestClient("https://wbudget.app/api/v1/api/v1/clients");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"name\": \"Empresa Exemplo\",\n  \"email\": \"contato@example.com\",\n  \"phone\": \"+5511999990000\",\n  \"national_id\": \"11222333000181\",\n  \"sponsor\": \"Ana Silva\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Clientes_Criar cliente_example
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [
  "name": "Empresa Exemplo",
  "email": "contato@example.com",
  "phone": "+5511999990000",
  "national_id": "11222333000181",
  "sponsor": "Ana Silva"
] as [String : Any]

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

let request = NSMutableURLRequest(url: NSURL(string: "https://wbudget.app/api/v1/api/v1/clients")! 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()
```