# Criar Pedido

## Criar pedido

> Cria um novo pedido de pagamento

```json
{"openapi":"3.0.0","info":{"title":"Barte Payment Service API - Pedidos","version":"2.0.0"},"servers":[{"url":"https://api.barte.com","description":"Servidor de Produção"},{"url":"https://sandbox-api.barte.com","description":"Servidor de Sandbox"}],"security":[{"ApiKeyAuth":[]}],"components":{"securitySchemes":{"ApiKeyAuth":{"type":"apiKey","in":"header","name":"X-Token-Api","description":"Token de autenticação para acesso à API"}},"schemas":{"OrderRequest":{"type":"object","required":["startDate","value","installments","title","payment","uuidBuyer"],"properties":{"startDate":{"type":"string","format":"date"},"value":{"type":"number","format":"double"},"installments":{"type":"integer","minimum":1},"title":{"type":"string","maxLength":60},"description":{"type":"string","maxLength":300},"payment":{"$ref":"#/components/schemas/PaymentRequest"},"uuidBuyer":{"type":"string","format":"uuid"},"metadata":{"type":"array","items":{"$ref":"#/components/schemas/MetadataRequest"}}}},"PaymentRequest":{"type":"object","required":["method","card","fraudData"],"properties":{"method":{"type":"string","enum":["CREDIT_CARD","DEBIT_CARD","PIX","BANK_SLIP","CREDIT_CARD_EARLY_SELLER","CREDIT_CARD_EARLY_BUYER"]},"capture":{"type":"boolean","description":"Indica se a transação deve ser capturada imediatamente após a autorização"},"softDescriptor":{"type":"string","maxLength":13,"description":"Texto que aparecerá na fatura do cartão do comprador"},"card":{"$ref":"#/components/schemas/CardRequest"},"fraudData":{"$ref":"#/components/schemas/FraudDataRequest"},"storedCredential":{"$ref":"#/components/schemas/StoredCredentialRequest"}}},"CardRequest":{"type":"object","required":["holderName","number","expiration","cvv"],"properties":{"holderName":{"type":"string"},"number":{"type":"string"},"expiration":{"type":"string"},"cvv":{"type":"string"}}},"FraudDataRequest":{"type":"object","properties":{"document":{"type":"string"},"name":{"type":"string"},"email":{"type":"string","format":"email"},"phone":{"type":"string"},"internationalDocument":{"type":"object","properties":{"documentType":{"type":"string"},"documentNumber":{"type":"string"},"documentNation":{"type":"string"}}},"billingAddress":{"$ref":"#/components/schemas/BillingAddressRequest"},"additionalData":{"type":"object","nullable":true,"default":null,"description":"Objeto livre para enriquecer a análise de fraude com dados contextuais do pedido. Aceita qualquer estrutura JSON válida (ex: tipo de produto, canal de venda, informações do dispositivo)."}}},"BillingAddressRequest":{"type":"object","required":["country","state","city","district","street","zipCode","number"],"properties":{"country":{"type":"string"},"state":{"type":"string"},"city":{"type":"string"},"district":{"type":"string"},"street":{"type":"string"},"zipCode":{"type":"string"},"number":{"type":"string"},"complement":{"type":"string"}}},"StoredCredentialRequest":{"type":"object","required":["initiator","reason"],"properties":{"initiator":{"type":"string","enum":["CARDHOLDER","MERCHANT"],"description":"Quem iniciou a transação: CARDHOLDER (cliente autorizou) ou MERCHANT (seller iniciou automaticamente)"},"reason":{"type":"string","enum":["INITIAL","RECURRING","INSTALLMENT","UNSCHEDULED"],"description":"Tipo de recorrência: INITIAL (primeira transação), RECURRING (cobrança fixa), INSTALLMENT (parcelamento), UNSCHEDULED (cobrança avulsa)"}}},"MetadataRequest":{"type":"object","required":["key","value"],"properties":{"key":{"type":"string"},"value":{"oneOf":[{"type":"string"},{"type":"number"}]}}},"OrderResponse":{"type":"object","properties":{"uuid":{"type":"string","format":"uuid"},"status":{"type":"string","enum":["SENT","ABANDONED","PAID","CANCELED","LATE","PARTIALLY_PAID","REFUND","CHARGEBACK","PRE_AUTHORIZED"]},"title":{"type":"string","maxLength":60},"description":{"type":"string","maxLength":300},"value":{"type":"number","format":"double"},"installments":{"type":"integer"},"startDate":{"type":"string","format":"date"},"payment":{"type":"string","enum":["CREDIT_CARD","DEBIT_CARD","PIX","BANK_SLIP","CREDIT_CARD_EARLY_SELLER","CREDIT_CARD_EARLY_BUYER"]},"customer":{"$ref":"#/components/schemas/CustomerResponse"},"idempotencyKey":{"type":"string","format":"uuid"},"subSellerPaymentResponse":{"type":"array","items":{"$ref":"#/components/schemas/SubSellerPaymentResponse"}},"charges":{"type":"array","items":{"$ref":"#/components/schemas/ChargeResponse"}}}},"CustomerResponse":{"type":"object","properties":{"uuid":{"type":"string"},"document":{"type":"string"},"type":{"type":"string","enum":["CPF","CNPJ","SSN"]},"documentCountry":{"type":"string"},"name":{"type":"string"},"email":{"type":"string","format":"email"},"phone":{"type":"string"},"alternativeEmail":{"type":"string"}}},"SubSellerPaymentResponse":{"type":"object","properties":{"subSellerPaymentResponse":{"type":"array","items":{"type":"object"}},"amountForSubSellers":{"type":"number","format":"double"}}},"ChargeResponse":{"type":"object","properties":{"uuid":{"type":"string","format":"uuid"},"title":{"type":"string","maxLength":60},"expirationDate":{"type":"string","format":"date"},"paidDate":{"type":"string","format":"date"},"value":{"type":"number","format":"double"},"paymentMethod":{"type":"string","enum":["CREDIT_CARD","DEBIT_CARD","PIX","BANK_SLIP","CREDIT_CARD_EARLY_SELLER","CREDIT_CARD_EARLY_BUYER"]},"status":{"type":"string","enum":["SENT","ABANDONED","PAID","CANCELED","LATE","PARTIALLY_PAID","REFUND","CHARGEBACK","PRE_AUTHORIZED"]},"customer":{"$ref":"#/components/schemas/CustomerResponse"},"authorizationCode":{"type":"string"},"authorizationNsu":{"type":"string"},"refunds":{"type":"array","items":{"type":"object"}},"retryable":{"type":"boolean"},"fee":{"type":"number","format":"double"}}},"Error":{"type":"object","properties":{"errors":{"type":"array","items":{"$ref":"#/components/schemas/ErrorDetail"}},"metadata":{"$ref":"#/components/schemas/Metadata"}}},"ErrorDetail":{"type":"object","properties":{"status":{"type":"string"},"code":{"type":"string","enum":["PAYMENT-0000","PAYMENT-0500","PAYMENT-9999","BAR-0300","BAR-0502","BAD_REQUEST","FORBIDDEN","METHOD_NOT_ALLOWED","NOT_ACCEPTABLE","UNSUPPORTED_MEDIA_TYPE","BAR-7001"]},"title":{"type":"string","enum":["BUSINESS_SELLER","BUSINESS_CHECKOUT","BUSINESS_COMMON","BUSINESS_SECURITY","BUSINESS_SUBSCRIPTION","INVALID_REQUEST_PARAM","BUSINESS_METRIC","BUSINESS_ACCOUNTANCY","BUSINESS_NOTIFICATION","BUSINESS_BARTE","BUSINESS_COMPANY","BUSINESS_INVOICE","BUSINESS_TRANSFER","BUSINESS_CARD","BUSINESS_ORDER","card_not_supported"]},"description":{"type":"string"},"action":{"type":"string"},"additionalInfo":{"type":"object","additionalProperties":{"type":"object"}}}},"Metadata":{"type":"object","properties":{"totalRecords":{"type":"integer"},"totalPages":{"type":"integer"},"requestDatetime":{"type":"string","format":"date-time"}}}}},"paths":{"/v2/orders":{"post":{"summary":"Criar pedido","description":"Cria um novo pedido de pagamento","tags":["Pedidos"],"parameters":[{"name":"X-Token-Api","in":"header","required":true,"schema":{"type":"string"},"description":"Token de autenticação para acesso à API"},{"name":"Content-Type","in":"header","required":false,"schema":{"type":"string","enum":["application/json"]},"description":"Tipo de conteúdo da requisição"},{"name":"x-idempotency-key","in":"header","required":false,"schema":{"type":"string"},"description":"Chave de idempotência para evitar duplicidade"},{"name":"x-ip-origin-request","in":"header","required":false,"schema":{"type":"string"},"description":"IP de origem da requisição"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/OrderRequest"}}}},"responses":{"200":{"description":"Pedido criado com sucesso","content":{"application/json":{"schema":{"$ref":"#/components/schemas/OrderResponse"}}}},"201":{"description":"Pedido criado com sucesso","content":{"application/json":{"schema":{"$ref":"#/components/schemas/OrderResponse"}}}},"400":{"description":"Erro de validação ou negócio","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Token inativo ou inexistente","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Acesso negado","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Recurso não encontrado","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Muitas requisições","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"500":{"description":"Erro interno do servidor","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}}}}
```
