Amili Docs
Home
Products
Products
  • Debt.collection
  • Account Receivable
  • Distribution
Go to amili.no
Home
Products
Products
  • Debt.collection
  • Account Receivable
  • Distribution
Go to amili.no
  1. AutoCollec API
  • About the AutoCollect API
  • Getting started with the AutoCollect API
  • Webhooks
  • AutoCollec API
    • Example Workflow
    • Batches
      • GetBatchById
      • GetBatchesByOrganization
    • Invoice
      • CreateInvoices
      • GetInvoicesByOrganization
      • GetInvoiceById
    • Payment
      • CreatePayments
    • Collections
      • AcceptDebtCollectionList
      • AcceptDebtCollectionList
      • RejectDebtCollectionList
      • PauseCase
      • RejectDebtCollectionList
      • WithdrawCase
      • PauseCase
      • ResumeCase
      • WithdrawCase
      • ResumeCase
    • Settlement
      • GetSettlement on Id
      • GetSettlements
      • GetSettlements
      • GetSettlement on Id
  • AutoCollect API (Legacy)
    • Attachment
      • /webapi/api/Attachment
    • Batch
      • /webapi/api/Batch
      • /webapi/api/Batch
    • Ping
      • /webapi/api/Ping
Home
Products
Products
  • Debt.collection
  • Account Receivable
  • Distribution
Go to amili.no
Home
Products
Products
  • Debt.collection
  • Account Receivable
  • Distribution
Go to amili.no
  1. AutoCollec API

Example Workflow

This guide covers the end-to-end workflow for submitting invoices to Amili Collection API: authenticating with Identiverse, creating an invoice batch, and polling the batch result.

Flow Overview#

1. Authenticate  →  POST {identiverse_base_url}/token
2. Create invoices  →  POST /collection/v1/orgs/{orgId}/invoices
3. Poll result  →  GET /collection/v1/batches/{batchId}
Invoice creation is asynchronous. The API accepts the request immediately and returns a batch reference. Poll the batch endpoint until the status changes from QUEUED to a terminal state (SUCCESS, PARTIAL, or FAILED).

Step 1 — Authenticate (POST /token)#

Obtain a Bearer token from Identiverse using the OAuth 2.0 client credentials flow. Check out our Getting started section for how to get your ClientId and ClientSecret.
Environments
EnvironmentBase URL
Staginghttps://auth.staging.amili.no
Productionhttps://auth.amili.no

Endpoint#

Method: POST
URL: {identiverse_base_url}/token
Content-Type: application/x-www-form-urlencoded

Request body#

FieldValue
grant_typeclient_credentials
client_idYour assigned client ID
client_secretYour assigned client secret

Example#

POST https://auth.amili.no/token
Content-Type: application/x-www-form-urlencoded

grant_type=client_credentials&client_id=my-integration&client_secret=s3cr3t

Response#

{
  "access_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9...",
  "token_type": "Bearer",
  "not_before": 1709300000,
  "expires_in": 3600,
  "expires_on": 1709303600,
  "resource": "04468334-ec11-4ef8-9e7c-e124bacbd5c1"
}
FieldDescription
access_tokenInclude as Authorization: Bearer {access_token} on all subsequent requests
expires_inLifetime in seconds (typically 3600 s / 1 hour)
expires_onUnix timestamp when the token expires
Cache the token and reuse it until expires_on. Requesting a new token on every call will result in unnecessary latency.

Step 2 — Create Invoices (POST /orgs/{orgId}/invoices)#

Submit one or more invoices for processing. The request is queued asynchronously and a batch reference is returned immediately.

Endpoint#

Method: POST
URL: /collection/v1/orgs/{orgId}/invoices
Authorization: Bearer {access_token}
Required permission: write:collection.case
Content-Type: application/json

Path parameters#

ParameterTypeDescription
orgIdUUIDThe organization identifier issued by Amili

Request body#

{
  "invoices": [ <Invoice>, ... ]
}

Example request#

POST https://api.staging.amili.no/collection/v1/orgs/3fa85f64-5717-4562-b3fc-2c963f66afa6/invoices
Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9...
Content-Type: application/json

{
  "invoices": [
    {
      "type": "NOTICE",
      "invoiceNumber": "INV-2024-00123",
      "originalInvoiceAmount": 4500.00,
      "currency": "NOK",
      "invoiceDate": "2024-01-15T00:00:00Z",
      "dueDate": "2024-02-15T00:00:00Z",
      "uniqueSourceInvoiceId": "erp-order-9981",
      "description": "Consulting services January 2024",
      "ocrReferenceNumber": "123456789",
      "debtors": [
        {
          "type": "PRIVATE",
          "firstname": "Kari",
          "lastname": "Nordmann",
          "customerNumber": "CUST-001",
          "identificationNumber": "12345678901",
          "emails": [
            { "value": "kari.nordmann@example.com" }
          ],
          "phoneNumbers": [
            { "value": "+4798765432", "countryCode": "NO" }
          ],
          "addresses": [
            {
              "street": "Storgata 1",
              "city": "Oslo",
              "zipCode": "0155",
              "countryCode": "NO"
            }
          ]
        }
      ],
      "claims": [
        {
          "type": "PRINCIPAL",
          "remainingAmount": 4500.00,
          "description": "Main invoice amount"
        }
      ]
    }
  ]
}

Response — 202 Accepted#

{
  "data": {
    "batchId": "d290f1ee-6c54-4b01-90e6-d701748f0851",
    "batchUrl": "https://api.staging.amili.no/collection/v1/batches/d290f1ee-6c54-4b01-90e6-d701748f0851"
  }
}
FieldDescription
batchIdUUID of the created batch. Use this to poll the result
batchUrlAbsolute URL to the batch resource

Step 3 — Get Batch Result (GET /batches/{batchId})#

Poll this endpoint after creating an invoice batch to check processing status and retrieve per-invoice results.

Endpoint#

Method: GET
URL: /collection/v1/batches/{batchId}
Authorization: Bearer {access_token}

Path parameters#

ParameterTypeDescription
batchIdUUIDThe batch ID returned from the invoice creation response

Example request#

GET https://api.staging.amili.no/collection/v1/batches/d290f1ee-6c54-4b01-90e6-d701748f0851
Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9...

Response — 200 OK#

{
  "data": {
    "batchId": "d290f1ee-6c54-4b01-90e6-d701748f0851",
    "type": "INVOICE",
    "status": "PARTIAL",
    "createdAt": "2024-01-15T10:30:00Z",
    "finishedAt": "2024-01-15T10:30:05Z",
    "organizationId": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
    "createdBy": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
    "succeeded": [
      {
        "type": "INVOICE",
        "invoiceId": "7c9e6679-7425-40de-944b-e07fc1f90ae7",
        "invoiceNumber": "INV-2024-00123",
        "caseId": "f47ac10b-58cc-4372-a567-0e02b2c3d479",
        "caseNumber": "CASE-2024-00456"
      }
    ],
    "failed": [
      {
        "type": "INVOICE",
        "invoiceNumber": "INV-2024-00124",
        "errors": ["Debtor identification number is invalid"]
      }
    ]
  }
}

Batch status values#

StatusTerminalDescription
QUEUED❌Batch received and waiting to be processed. Keep polling
SUCCESS✅All invoices in the batch were processed successfully
PARTIAL✅Some invoices succeeded, some failed. Check succeeded and failed arrays
FAILED✅All invoices in the batch failed

Batch response fields#

FieldTypeDescription
batchIdUUIDIdentifies the batch
typestringAlways INVOICE for invoice batches
statusstringSee status table above
createdAtdatetimeWhen the batch was queued
finishedAtdatetime | nullWhen processing completed. null while still QUEUED
organizationIdUUIDOrganization that owns this batch
createdByUUIDIdentity that submitted the batch
succeededarrayPer-invoice success results
failedarrayPer-invoice failure results

Succeeded item fields#

FieldDescription
invoiceIdUUID of the created invoice in the collection system
invoiceNumberThe invoice number from your request
caseIdUUID of the collection case created for this invoice
caseNumberHuman-readable case reference

Failed item fields#

FieldDescription
invoiceNumberThe invoice number from your request
errorsList of error messages explaining why processing failed

Recommended Polling Strategy#

Since the batch is processed asynchronously, poll with exponential backoff to avoid hammering the API:
Attempt 1: wait 1 s
Attempt 2: wait 2 s
Attempt 3: wait 4 s
Attempt 4: wait 8 s
...
Max interval: 30 s
Timeout after: 5 min
Stop polling when status is SUCCESS, PARTIAL, or FAILED.
Modified at 2026-03-09 14:20:11
Previous
AutoCollec API
Next
GetBatchById
Built with