Deletar categorias
Deleta uma ou mais categorias customizadas da empresa autenticada. Cada item em changes identifica uma categoria a deletar. Se a categoria tiver estabelecimentos vinculados, é obrigatório informar moveTo para reatribuí-los a outra categoria antes da exclusão — omitir quando há estabelecimentos retorna 422.
curl -X DELETE "https://api-sandbox.contasimples.com/categories/v1/categories" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_TOKEN" \
-d '{
"changes": [
{
"categoryToDelete": 100323,
"moveTo": {
"categoryId": 200,
"establishments": [
10045,
10046
]
}
},
{
"categoryToDelete": 100324
}
]
}'
import requests
import json
url = "https://api-sandbox.contasimples.com/categories/v1/categories"
headers = {
"Content-Type": "application/json",
"Authorization": "Bearer YOUR_API_TOKEN"
}
data = {
"changes": [
{
"categoryToDelete": 100323,
"moveTo": {
"categoryId": 200,
"establishments": [
10045,
10046
]
}
},
{
"categoryToDelete": 100324
}
]
}
response = requests.delete(url, headers=headers, json=data)
print(response.json())
const response = await fetch("https://api-sandbox.contasimples.com/categories/v1/categories", {
method: "DELETE",
headers: {
"Content-Type": "application/json",
"Authorization": "Bearer YOUR_API_TOKEN"
},
body: JSON.stringify({
"changes": [
{
"categoryToDelete": 100323,
"moveTo": {
"categoryId": 200,
"establishments": [
10045,
10046
]
}
},
{
"categoryToDelete": 100324
}
]
})
});
const data = await response.json();
console.log(data);
package main
import (
"fmt"
"net/http"
"bytes"
"encoding/json"
)
func main() {
data := []byte(`{
"changes": [
{
"categoryToDelete": 100323,
"moveTo": {
"categoryId": 200,
"establishments": [
10045,
10046
]
}
},
{
"categoryToDelete": 100324
}
]
}`)
req, err := http.NewRequest("DELETE", "https://api-sandbox.contasimples.com/categories/v1/categories", bytes.NewBuffer(data))
if err != nil {
panic(err)
}
req.Header.Set("Content-Type", "application/json")
req.Header.Set("Authorization", "Bearer YOUR_API_TOKEN")
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
fmt.Println("Response Status:", resp.Status)
}
require 'net/http'
require 'json'
uri = URI('https://api-sandbox.contasimples.com/categories/v1/categories')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Delete.new(uri)
request['Content-Type'] = 'application/json'
request['Authorization'] = 'Bearer YOUR_API_TOKEN'
request.body = '{
"changes": [
{
"categoryToDelete": 100323,
"moveTo": {
"categoryId": 200,
"establishments": [
10045,
10046
]
}
},
{
"categoryToDelete": 100324
}
]
}'
response = http.request(request)
puts response.body
{}
{
"error": "Bad Request",
"message": "The request contains invalid parameters or malformed data",
"code": 400,
"details": [
{
"field": "email",
"message": "Invalid email format"
}
]
}
{
"error": "Unauthorized",
"message": "Authentication required. Please provide a valid API token",
"code": 401
}
{
"error": "Not Found",
"message": "The requested resource was not found",
"code": 404
}
{
"error": "Conflict",
"message": "The request conflicts with the current state of the resource",
"code": 409,
"details": "Resource already exists"
}
{
"error": "Unprocessable Entity",
"message": "The request was well-formed but contains semantic errors",
"code": 422,
"details": [
{
"field": "password",
"message": "Password must be at least 8 characters long"
}
]
}
{
"error": "Internal Server Error",
"message": "An unexpected error occurred on the server",
"code": 500,
"requestId": "req_1234567890"
}
DELETE
/categories/v1/categories
DELETE
Base URLstring
Target server for requests. Edit to use your own host.
Bearer Token
Bearer Tokenstring
RequiredToken Bearer obtido via OAuth 2.0 Client Credentials. Formato: Bearer TOKEN
Token Bearer obtido via OAuth 2.0 Client Credentials. Formato:
Bearer TOKENContent-Typestring
RequiredThe media type of the request body
Options: application/json
changesarray
RequiredLista de categorias a deletar. Deve conter ao menos um item.
Request Preview
Response
Response will appear here after sending the request
Authentication
header
Authorizationstring
RequiredBearer token. Token Bearer obtido via OAuth 2.0 Client Credentials. Formato: Bearer TOKEN
Body
application/json
changesarray
RequiredLista de categorias a deletar. Deve conter ao menos um item.
Responses
Was this page helpful?