Cadastrar um Armazém
Descrição: Cadastra um novo Armazém associado a uma Companhia Produtora.
Endpoint
POST/api/v1/integration/warehouses/-/producers/{producer_id}
Regras
| Atributos | Descrição | Tipo | Obrigatório | Validações |
|---|---|---|---|---|
| producer_id | Identificador da Companhia Produtora | UUID | Sim | _ |
| name | Nome | String | Sim | Até 250 caracteres. |
| document | CNPJ | String | Sim | Aceita apenas números. Não pode ser repetido o mesmo CNPJ para a Companhia Produtora |
| capacity | Capacidade | Number | Sim | Apenas números. Aceita até 8 dígitos inteiros e 2 dígitos decimais |
| state_subscription | Inscrição estadual | String | Não | Se preenchido, deverá conter a inscrição e o Estado separados por hífen(-). Exemplo: 123456-MS |
| state_subscription_uf | UF da inscrição estadual | String | Não | Sigla do estado (ex: MS) |
| address.street | Rua | String | Sim | Até 250 caracteres. |
| address.number | Numero | String | Sim | Apenas números. Até 10 caracteres. |
| address.complement | Complemento | String | Não | Até 100 caracteres. |
| address.neighborhood | Bairro | String | Sim | Até 100 caracteres. |
| address.zip_code | CEP | String | Sim | CEP com "-" |
| address.city | Cidade | String | Sim | Até 100 caracteres. |
| address.state | Estado | String | Sim | Até 2 caracteres. |
| address.country | Pais | String | Sim | Até 50 caracteres. |
Exemplo de Requisição
- cURL
- Java
- JavaScript
- Python
curl -X POST \
-H "Authorization: {SUA_API_KEY}" \
-H "Content-Type: application/json" \
-d '{
"name": "Armazém Central MT",
"document": "12345678000190",
"capacity": 5000.00,
"state_subscription": "123456-MT",
"state_subscription_uf": "MT",
"address": {
"street": "Av. das Indústrias",
"number": "1000",
"complement": "Galpão 3",
"neighborhood": "Distrito Industrial",
"zip_code": "78705-060",
"city": "Sorriso",
"state": "MT",
"country": "Brasil"
}
}' \
"https://api.merx.tech/api/v1/integration/warehouses/-/producers/{producer_id}"
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
String body = "{\"name\": \"Armazém Central MT\", \"document\": \"12345678000190\", \"capacity\": 5000.00, \"state_subscription\": \"123456-MT\", \"state_subscription_uf\": \"MT\", \"address\": {\"street\": \"Av. das Indústrias\", \"number\": \"1000\", \"complement\": \"Galpão 3\", \"neighborhood\": \"Distrito Industrial\", \"zip_code\": \"78705-060\", \"city\": \"Sorriso\", \"state\": \"MT\", \"country\": \"Brasil\"}}";
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://api.merx.tech/api/v1/integration/warehouses/-/producers/{producer_id}"))
.header("Authorization", "{SUA_API_KEY}")
.header("Content-Type", "application/json")
.POST(HttpRequest.BodyPublishers.ofString(body))
.build();
HttpClient client = HttpClient.newHttpClient();
try {
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
} catch (Exception e) {
e.printStackTrace();
}
const response = await fetch(
'https://api.merx.tech/api/v1/integration/warehouses/-/producers/{producer_id}',
{
method: 'POST',
headers: {
'Authorization': '{SUA_API_KEY}',
'Content-Type': 'application/json',
},
body: JSON.stringify({
name: 'Armazém Central MT',
document: '12345678000190',
capacity: 5000.00,
state_subscription: '123456-MT',
state_subscription_uf: 'MT',
address: {
street: 'Av. das Indústrias',
number: '1000',
complement: 'Galpão 3',
neighborhood: 'Distrito Industrial',
zip_code: '78705-060',
city: 'Sorriso',
state: 'MT',
country: 'Brasil',
},
}),
}
);
const data = await response.json();
console.log(data);
import requests
url = "https://api.merx.tech/api/v1/integration/warehouses/-/producers/{producer_id}"
headers = {
"Authorization": "{SUA_API_KEY}",
"Content-Type": "application/json"
}
payload = {
"name": "Armazém Central MT",
"document": "12345678000190",
"capacity": 5000.00,
"state_subscription": "123456-MT",
"state_subscription_uf": "MT",
"address": {
"street": "Av. das Indústrias",
"number": "1000",
"complement": "Galpão 3",
"neighborhood": "Distrito Industrial",
"zip_code": "78705-060",
"city": "Sorriso",
"state": "MT",
"country": "Brasil"
}
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
Parâmetros
Parâmetros de Caminho:
| Nome | Descrição | Tipo | Obrigatório |
|---|---|---|---|
| producer_id | Identificador da Companhia Produtora | String | Sim |
Parâmetros de Cabeçalho
| Nome | Descrição | Tipo | Obrigatório |
|---|---|---|---|
| Authorization | Chave de API obtida via support-api@merx.tech | String | Sim |
| Content-Type | application/json | String | Sim |
Parâmetros do Corpo
| Nome | Descrição | Tipo | Obrigatório |
|---|---|---|---|
| name | Nome | String | Sim |
| document | CNPJ | String | Sim |
| state_subscription | Inscrição estadual | String | Não |
| state_subscription_uf | UF da inscrição estadual | String | Não |
| capacity | Capacidade | Number | Sim |
| address.street | Rua | String | Sim |
| address.number | Numero | String | Sim |
| address.complement | Complemento | String | Não |
| address.neighborhood | Bairro | String | Sim |
| address.zip_code | CEP | String | Sim |
| address.city | Cidade | String | Sim |
| address.state | Estado | String | Sim |
| address.country | Pais | String | Sim |
Respostas
- 200 - Ok
{
"id": "string"
}
- 400 - Bad Request
{
"messages": ["message.entidade.campo-inválido"]
}
401 - Unauthorized
404 - NotFound