Boleto Simples
agora é Kobana

Nos tornamos uma plataforma mais segura e eficiente, agora somos Kobana. Focada em tudo aquilo que você precisa, e portanto, focada totalmente em você!

Documentação da Kobana

Documentação para Desenvolvedores

CNAB (Retorno)

Recurso Descrição
POST /api/v1/discharges Enviar CNAB
GET /api/v1/discharges/:id Informações do CNAB
GET /api/v1/discharges Listar CNABs
PUT /api/v1/discharges/:id/pay_off Quitar boletos
PUT /api/v1/discharges/:id/reprocess Reprocessar CNAB
GET /api/v1/discharges/:id/download Download do CNAB

Modelo de Dados

Parâmetro Obrigatório Tipo Tamanho Descrição
id N/A Integer   ID do CNAB
file Sim     Arquivo
filename Não String 255 Nome do arquivo
status N/A String 20 Situação do arquivo (possíveis valores)
processed_at N/A DateTime   Data de Processamento
created_via_api N/A Boolean   Enviado pela API
bank_billet_account_id Não Integer   ID da Carteira de Cobrança
created_via_integration Não DateTime   Data de recebimento automático do banco
bank_billet_discharges N/A Array   Retornos bancários

Dicionário de Dados

status

unprocessed Pendente
processed Processado

Enviar CNAB

POST /api/v1/discharges

Exemplo de requisição inválida

Requisição:
curl -i \
-H "Authorization: Bearer $BOLETOSIMPLES_TOKEN" \
-H 'Content-Type: multipart/form-data' \
-H 'User-Agent: MyApp (myapp@example.com)' \
-X POST 'https://api-sandbox.kobana.com.br/v1/discharges'
Resposta:
HTTP/1.1 422 Unprocessable Entity
Server: Cowboy
Connection: keep-alive
Strict-Transport-Security: max-age=2592000
Content-Type: application/json; charset=utf-8
...

{"errors":{"discharge":["não pode ficar em branco"]}}

Exemplo de requisição válida

Requisição:
curl -i \
-H "Authorization: Bearer $BOLETOSIMPLES_TOKEN" \
-H 'Content-Type: multipart/form-data' \
-H 'User-Agent: MyApp (myapp@example.com)' \
-F "discharge[file]=@cnab240.ret" \
-X POST 'https://api-sandbox.kobana.com.br/v1/discharges'
Resposta:
HTTP/1.1 201 Created
Server: Cowboy
Connection: keep-alive
Strict-Transport-Security: max-age=2592000
Location: https://api-sandbox.kobana.com.br/v1/discharges/1
Content-Type: application/json; charset=utf-8
...

{
  "id":1,
  "filename":"cnab240.ret",
  "processed_at":"2015-06-11T10:41:41.916-03:00",
  "created_via_api":true,
  "status":"unprocessed"
}

Informações do CNAB

GET /api/v1/discharges/:id

Exemplo

Requisição:
curl -i \
-H "Authorization: Bearer $BOLETOSIMPLES_TOKEN" \
-H 'Content-Type: application/json' \
-H 'User-Agent: MyApp (myapp@example.com)' \
-X GET 'https://api-sandbox.kobana.com.br/v1/discharges/1'
Resposta:
HTTP/1.1 200 OK
Server: Cowboy
Connection: keep-alive
Strict-Transport-Security: max-age=2592000
Content-Type: application/json; charset=utf-8
...

{
  "id": 1,
  "filename": "1804191.RET",
  "processed_at": "2018-04-19",
  "created_via_api": false,
  "status": "processed",
  "bank_billet_account_id": 1,
  "created_via_integration": "2018-04-19T03:03:06-03:00",
  "bank_billet_discharges": [
    {
      "id": 1,
      "occurrence": "06",
      "date_of_occurrence": "2018-04-18",
      "discharge_id": 1,
      "bank_billet_id": 1,
      "occurrence_error": "0000000004",
      "line_parsed": {
        "iof": "0",
        "line_t": "7560001300007T 0604327000000000366680000070439401014     100000000007043920042018000000000014000341056140                         091000010759039984                    00000000000000000000002200000000004                 ",
        "line_u": "7560001300008U 060000000000000000000000000000000000000000000000000000000000000000000000140000000000000140000000000000000000000000000000001804201819042018    00000000000000000000000                              75600000000000000000000       ",
        "paid_at": "2018-04-18",
        "discount": "0",
        "bank_rate": "220",
        "credit_at": "2018-04-19",
        "error_code": "0000000004",
        "event_type": "06",
        "our_number": "00704394",
        "billet_fine": "0",
        "other_fines": "0",
        "paid_amount": "14000",
        "other_credit": "0",
        "value_rebate": "0",
        "agency_number": "4327",
        "credit_amount": "14000",
        "account_number": "00003666",
        "banco_recebedor": "341",
        "agencia_recebedora": "05614",
        "processed_our_number_raw": "00704394"
      },
      "processed_at": "2018-04-19",
      "occurrence_detail": "Liquidação Normal",
      "occurrence_error_detail": "756 - 06 - 0000000004 - Não Reconhecido"
    },
    {
      "id": 2,
      "occurrence": "06",
      "date_of_occurrence": "2018-04-18",
      "discharge_id": 1,
      "bank_billet_id": 2,
      "occurrence_error": "0000000004",
      "line_parsed": {
        "iof": "0",
        "line_t": "7560001300005T 0604327000000000366680000070424401014     100000000007042419042018000000000005000341032120                         092027613530000161                            00000000000000000000002200000000004                 ",
        "line_u": "7560001300006U 060000000000000000000000000000000000000000000000000000000000000000000000050000000000000050000000000000000000000000000000001804201819042018    00000000000000000000000                              75600000000000000000000       ",
        "paid_at": "2018-04-18",
        "discount": "0",
        "bank_rate": "220",
        "credit_at": "2018-04-19",
        "error_code": "0000000004",
        "event_type": "06",
        "our_number": "00704244",
        "billet_fine": "0",
        "other_fines": "0",
        "paid_amount": "5000",
        "other_credit": "0",
        "value_rebate": "0",
        "agency_number": "4327",
        "credit_amount": "5000",
        "account_number": "00003666",
        "banco_recebedor": "341",
        "agencia_recebedora": "03212",
        "processed_our_number_raw": "00704244"
      },
      "processed_at": "2018-04-19",
      "occurrence_detail": "Liquidação Normal",
      "occurrence_error_detail": "756 - 06 - 0000000004 - Não Reconhecido"
    },
    {
      "id": 3,
      "occurrence": "06",
      "date_of_occurrence": "2018-04-18",
      "discharge_id": 1,
      "bank_billet_id": 3,
      "occurrence_error": "0000000004",
      "line_parsed": {
        "iof": "0",
        "line_t": "7560001300003T 0604327000000000366680000070417201014     100000000007041718042018000000000041233001037960                         091000022126830225                  00000000000000000000002200000000004                 ",
        "line_u": "7560001300004U 060000000000000000000000000000000000000000000000000000000000000000000000412330000000000412330000000000000000000000000000001804201819042018    00000000000000000000000                              75600000000000000000000       ",
        "paid_at": "2018-04-18",
        "discount": "0",
        "bank_rate": "220",
        "credit_at": "2018-04-19",
        "error_code": "0000000004",
        "event_type": "06",
        "our_number": "00704172",
        "billet_fine": "0",
        "other_fines": "0",
        "paid_amount": "41233",
        "other_credit": "0",
        "value_rebate": "0",
        "agency_number": "4327",
        "credit_amount": "41233",
        "account_number": "00003666",
        "banco_recebedor": "001",
        "agencia_recebedora": "03796",
        "processed_our_number_raw": "00704172"
      },
      "processed_at": "2018-04-19",
      "occurrence_detail": "Liquidação Normal",
      "occurrence_error_detail": "756 - 06 - 0000000004 - Não Reconhecido"
    },
    {
      "id": 4,
      "occurrence": "02",
      "date_of_occurrence": "2018-04-18",
      "discharge_id": 1,
      "bank_billet_id": 4,
      "occurrence_error": "",
      "line_parsed": {
        "iof": "0",
        "line_t": "7560001300001T 0204327000000000366680000070439401014     100000000007043920042018000000000014000756043270                         091000010759039984                    0000000000000000000000020                           ",
        "line_u": "7560001300002U 020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001804201800000000    00000000000000000000000                              75600000000000000000000       ",
        "paid_at": "2018-04-18",
        "discount": "0",
        "bank_rate": "20",
        "credit_at": null,
        "error_code": "",
        "event_type": "02",
        "our_number": "00704394",
        "billet_fine": "0",
        "other_fines": "0",
        "paid_amount": "0",
        "other_credit": "0",
        "value_rebate": "0",
        "agency_number": "4327",
        "credit_amount": "0",
        "account_number": "00003666",
        "banco_recebedor": "756",
        "agencia_recebedora": "04327",
        "processed_our_number_raw": "00704394"
      },
      "processed_at": "2018-04-19",
      "occurrence_detail": "Confirmação Entrada Título",
      "occurrence_error_detail": null
    }
  ]
}
Requisição:
@discharge = BoletoSimples::Discharge.find(1)
ap @discharge.attributes
Resposta:
{
            "id" => 1
            "filename" => "1804191.RET",
            "processed_at" => "2018-04-19",
            "created_via_api" => false,
            "status" => "processed",
            "bank_billet_account_id" => 1,
           "created_via_integration" => "2018-04-19T03:03:06-03:00",
            "bank_billet_discharges" => [
            {
                                 "id" => 1,
                         "occurrence" => "06",
                 "date_of_occurrence" => "2018-04-18",
                       "discharge_id" => 1,
                     "bank_billet_id" => 1,
                   "occurrence_error" => "0000000004",
                        "line_parsed" => {
                                     "iof" => "0",
                                  "line_t" => "7560001300007T 0604327000000000366680000070439401014     100000000007043920042018000000000014000341056140                         091000010759039984                    00000000000000000000002200000000004                 ",
                                  "line_u" => "7560001300008U 060000000000000000000000000000000000000000000000000000000000000000000000140000000000000140000000000000000000000000000000001804201819042018    00000000000000000000000                              75600000000000000000000       ",
                                 "paid_at" => "2018-04-18",
                                "discount" => "0",
                               "bank_rate" => "220",
                               "credit_at" => "2018-04-19",
                              "error_code" => "0000000004",
                              "event_type" => "06",
                              "our_number" => "00704394",
                             "billet_fine" => "0",
                             "other_fines" => "0",
                             "paid_amount" => "14000",
                            "other_credit" => "0",
                            "value_rebate" => "0",
                           "agency_number" => "4327",
                           "credit_amount" => "14000",
                          "account_number" => "00003666",
                         "banco_recebedor" => "341",
                      "agencia_recebedora" => "05614",
                "processed_our_number_raw" => "00704394"
            },
                       "processed_at" => "2018-04-19",
                  "occurrence_detail" => "Liquidação Normal",
            "occurrence_error_detail" => "756 - 06 - 0000000004 - Não Reconhecido"
        },
         {
                                 "id" => 2,
                         "occurrence" => "06",
                 "date_of_occurrence" => "2018-04-18",
                       "discharge_id" => 1,
                     "bank_billet_id" => 2,
                   "occurrence_error" => "0000000004",
                        "line_parsed" => {
                                     "iof" => "0",
                                  "line_t" => "7560001300005T 0604327000000000366680000070424401014     100000000007042419042018000000000005000341032120                         092027613530000161                            00000000000000000000002200000000004                 ",
                                  "line_u" => "7560001300006U 060000000000000000000000000000000000000000000000000000000000000000000000050000000000000050000000000000000000000000000000001804201819042018    00000000000000000000000                              75600000000000000000000       ",
                                 "paid_at" => "2018-04-18",
                                "discount" => "0",
                               "bank_rate" => "220",
                               "credit_at" => "2018-04-19",
                              "error_code" => "0000000004",
                              "event_type" => "06",
                              "our_number" => "00704244",
                             "billet_fine" => "0",
                             "other_fines" => "0",
                             "paid_amount" => "5000",
                            "other_credit" => "0",
                            "value_rebate" => "0",
                           "agency_number" => "4327",
                           "credit_amount" => "5000",
                          "account_number" => "00003666",
                         "banco_recebedor" => "341",
                      "agencia_recebedora" => "03212",
                "processed_our_number_raw" => "00704244"
            },
                       "processed_at" => "2018-04-19",
                  "occurrence_detail" => "Liquidação Normal",
            "occurrence_error_detail" => "756 - 06 - 0000000004 - Não Reconhecido"
        },
        {
                                 "id" => 3,
                         "occurrence" => "06",
                 "date_of_occurrence" => "2018-04-18",
                       "discharge_id" => 1,
                     "bank_billet_id" => 3,
                   "occurrence_error" => "0000000004",
                        "line_parsed" => {
                                     "iof" => "0",
                                  "line_t" => "7560001300003T 0604327000000000366680000070417201014     100000000007041718042018000000000041233001037960                         091000022126830225                  00000000000000000000002200000000004                 ",
                                  "line_u" => "7560001300004U 060000000000000000000000000000000000000000000000000000000000000000000000412330000000000412330000000000000000000000000000001804201819042018    00000000000000000000000                              75600000000000000000000       ",
                                 "paid_at" => "2018-04-18",
                                "discount" => "0",
                               "bank_rate" => "220",
                               "credit_at" => "2018-04-19",
                              "error_code" => "0000000004",
                              "event_type" => "06",
                              "our_number" => "00704172",
                             "billet_fine" => "0",
                             "other_fines" => "0",
                             "paid_amount" => "41233",
                            "other_credit" => "0",
                            "value_rebate" => "0",
                           "agency_number" => "4327",
                           "credit_amount" => "41233",
                          "account_number" => "00003666",
                         "banco_recebedor" => "001",
                      "agencia_recebedora" => "03796",
                "processed_our_number_raw" => "00704172"
            },
                       "processed_at" => "2018-04-19",
                  "occurrence_detail" => "Liquidação Normal",
            "occurrence_error_detail" => "756 - 06 - 0000000004 - Não Reconhecido"
        },
        {
                                 "id" => 4,
                         "occurrence" => "02",
                 "date_of_occurrence" => "2018-04-18",
                       "discharge_id" => 1,
                     "bank_billet_id" => 4,
                   "occurrence_error" => "",
                        "line_parsed" => {
                                     "iof" => "0",
                                  "line_t" => "7560001300001T 0204327000000000366680000070439401014     100000000007043920042018000000000014000756043270                         091000010759039984                    0000000000000000000000020                           ",
                                  "line_u" => "7560001300002U 020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001804201800000000    00000000000000000000000                              75600000000000000000000       ",
                                 "paid_at" => "2018-04-18",
                                "discount" => "0",
                               "bank_rate" => "20",
                               "credit_at" => nil,
                              "error_code" => "",
                              "event_type" => "02",
                              "our_number" => "00704394",
                             "billet_fine" => "0",
                             "other_fines" => "0",
                             "paid_amount" => "0",
                            "other_credit" => "0",
                            "value_rebate" => "0",
                           "agency_number" => "4327",
                           "credit_amount" => "0",
                          "account_number" => "00003666",
                         "banco_recebedor" => "756",
                      "agencia_recebedora" => "04327",
                "processed_our_number_raw" => "00704394"
            },
                       "processed_at" => "2018-04-19",
                  "occurrence_detail" => "Confirmação Entrada Título",
            "occurrence_error_detail" => nil
        }
    ],
}

Download do CNAB

GET /api/v1/discharges/:id/download

Exemplo

Requisição:
  curl -i \
  -H "Authorization: Bearer $BOLETOSIMPLES_TOKEN" \
  -H 'Content-Type: application/json' \
  -H 'User-Agent: MyApp (myapp@example.com)' \
  -X GET 'https://api-sandbox.kobana.com.br/v1/discharges/1/download'
  
Resposta:
  HTTP/1.1 200 OK
  Server: Cowboy
  Connection: keep-alive
  Strict-Transport-Security: max-age=2592000
  Content-Type: application/octet-stream
  Content-Transfer-Encoding: binary
  ...
  02RETORNO01COBRANCA...
  

Listar CNABs

GET /api/v1/discharges

Parâmetro Obrigatório Tipo Descrição
page Não Number Número da Página
per_page Não Number Quantidade de registros por página (Máximo de 50)
bank_billet_account_id Não Number Filtro por ID da Carteira.
created_from Não Date A partir da Data de criação do Retorno
created_to Não Date Até a Data de criação do Retorno

Exemplo

Requisição:
curl -i \
-H "Authorization: Bearer $BOLETOSIMPLES_TOKEN" \
-H 'Content-Type: application/json' \
-H 'User-Agent: MyApp (myapp@example.com)' \
-X GET "https://api-sandbox.kobana.com.br/v1/discharges?page=1&per_page=50"
Resposta:
HTTP/1.1 200 OK
Server: Cowboy
Connection: keep-alive
Strict-Transport-Security: max-age=2592000
Total: 1
Content-Type: application/json; charset=utf-8
...

[
  {
    "id":1,
    "filename":"cnab240.ret",
    "processed_at":"2015-06-11T10:41:41.916-03:00",
    "created_via_api":true,
    "status":"processed"
  }
]

Quitar Boletos

PUT /api/v1/discharges/:id/pay_off ou PATCH /api/v1/discharges/:id/pay_off

É necessário já ter enviado o CNAB. Todos os boletos que forem identificados dentro do CNAB serão marcados como PAGO e os Webhooks serão disparados.

Exemplo

Requisição:
curl -i \
-H "Authorization: Bearer $BOLETOSIMPLES_TOKEN" \
-H 'Content-Type: application/json' \
-H 'User-Agent: MyApp (myapp@example.com)' \
-X PUT 'https://api-sandbox.kobana.com.br/v1/discharges/1/pay_off'
Resposta:
HTTP/1.1 204 OK
Server: Cowboy
Connection: keep-alive
Strict-Transport-Security: max-age=2592000
Content-Type: application/json; charset=utf-8
...

{
  "id":1,
  "filename":"cnab240.ret",
  "processed_at":"2015-06-11T10:41:41.916-03:00",
  "created_via_api":true,
  "status":"processed"
}

Reprocessar CNAB

PUT /api/v1/discharges/:id/reprocess ou PATCH /api/v1/discharges/:id/reprocess

Exemplo

Requisição:
curl -i \
-H "Authorization: Bearer $BOLETOSIMPLES_TOKEN" \
-H 'Content-Type: application/json' \
-H 'User-Agent: MyApp (myapp@example.com)' \
-X PUT 'https://api-sandbox.kobana.com.br/v1/discharges/1/reprocess'
Resposta:
HTTP/1.1 204 OK
Server: Cowboy
Connection: keep-alive
Strict-Transport-Security: max-age=2592000
Content-Type: application/json; charset=utf-8
...

{
  "id":1,
  "filename":"cnab240.ret",
  "processed_at":"2015-06-11T10:41:41.916-03:00",
  "created_via_api":true,
  "status":"processed"
}