Pular para o conteúdo principal
PUT
Update affiliate

📌 Endpoint

PUT /stores/{storeId}/affiliates/{affiliateId} Atualiza os dados de um afiliado (nome, e-mail, código, imagem, status, metadata e regras de comissão). Todos os campos são opcionais — apenas os enviados são alterados.

🔐 Autenticação

  • Rota privada.
  • Requer header Authorization com sua API key e plano ativo.

🧾 Parâmetros de rota


📤 Body (JSON)


✅ Exemplo de requisição


📦 Resposta de sucesso (200)


⚠️ Possíveis erros

  • 400 INVALID_DATA → body inválido
  • 400 INVALID_DATA_NAME → name fora de 1 a 56 caracteres
  • 400 INVALID_DATA_EMAIL → email inválido ou maior que 120 caracteres
  • 400 INVALID_DATA_IMAGE → image inválida (URL http/https inválida ou maior que 512 caracteres)
  • 400 INVALID_DATA_CODE → code fora de 3 a 50 caracteres ou fora do padrão slug
  • 400 INVALID_DATA_STATUS → status inválido (deve ser ativo ou inativo)
  • 400 INVALID_DATA_METADATA → metadata inválido (não é objeto ou excede 64 chaves)
  • 400 INVALID_DATA_RULES → commissionRules inválido (não é um array)
  • 400 INVALID_COMMISSION_RULES → commissionRules vazio
  • 400 INVALID_COMMISSION_RULE_TYPE → type inválido
  • 400 INVALID_COMMISSION_RULE_POSITION → position inválida/duplicada
  • 400 INVALID_COMMISSION_VALUE → commission fora de 1 a 100
  • 400 COMMISSION_RULE_DEFAULT_REQUIRED → falta exatamente uma regra DEFAULT
  • 400 INVALID_COMMISSION_RULE_TARGET → DEFAULT com targetId, ou PRODUCT/CATEGORY/COUPON sem targetId
  • 400 RELATION_NOT_FOUND → targetId de produto/categoria/cupom inexistente na loja
  • 401 API_KEY_NOT_PROVIDED → header Authorization não enviado
  • 401 INVALID_API_KEY → API key inválida
  • 401 UNAUTHENTICATED → usuário não autenticado
  • 403 USER_DISABLED → usuário desativado
  • 403 NO_ACTIVE_SUBSCRIPTION → sem plano ativo
  • 404 STORE_NOT_FOUND → loja não encontrada
  • 404 AFFILIATE_NOT_FOUND → afiliado não encontrado
  • 409 AFFILIATE_ALREADY_EXISTS → code já usado por outro afiliado
  • 409 AFFILIATE_EMAIL_ALREADY_EXISTS → e-mail já cadastrado por outro afiliado na loja
  • 429 RATE_LIMIT_EXCEEDED → limite de requisições por minuto excedido
  • 500 INTERNAL_SERVER_ERROR → erro interno
  • 503 SERVICE_UNAVAILABLE → serviço indisponível

Autorizações

Authorization
string
header
padrão:YOUR_API_KEY_HERE
obrigatório

Parâmetros de caminho

storeId
string
obrigatório
Required string length: 1 - 50
affiliateId
string
obrigatório
Required string length: 1 - 50

Corpo

application/json

Affiliate fields to update.

name
string
Required string length: 1 - 56
email
string<email>
Maximum string length: 120
code
string
Required string length: 3 - 50
Pattern: ^[a-z0-9]+(?:-[a-z0-9]+)*$
image
string | null
Maximum string length: 512
status
enum<string>
Opções disponíveis:
ativo,
inativo
metadata
object | null
commissionRules
object[]

Resposta

Update affiliate.

code
string
obrigatório
Exemplo:

"AFFILIATE_UPDATED"

affiliate
object
obrigatório

Store affiliate (referral code, commission, and stats).