Onea Transfer

From 1Archive help
Revision as of 15:40, 7 August 2017 by Gianni.vanhoecke (talk | contribs) (Added API key validation)

Jump to: navigation, search

1 Introduction

Sending thousands of invoices a day would have a negative impact on the stability of ScanPRO, and can be solved by a proxy. The goal of the proxy - Onea Transfer - is to take away the load on ScanPRO.

2 API

The ScanPRO Transfer API endpoint is https://transfer.onea.be. Please note that only HTTPS is available.

2.1 Upload e-Invoice

PATH: /restv1/einvoice/{type}

METHOD: POST

TYPE: JSON

DATA: apiKey, eInvoiceData, callbackURL

Where type is either incoming or outgoing.

Both apiKey and eInvoiceData are strings and mandatory fields, callbackURL is optional. The API key(s) will be provided by Onea and is strictly personal. The e-Invoice data field must be Base64 encoded.

When your request was successfully processed, the system will return a 200 OK status code with payload uuid. With this UUID you can later on fetch the document ID.

If you supply a callback URL, it will be notified of any change. That way you don't need to poll, but only fetch the status after you received such notification. Please note the callback URL will be appended with the UUID. If you supply the callback URL https://myapp.com/einvoice/poke, then the following URL will be called (POST) for UUID 123: https://myapp.com/einvoice/poke/123.

2.1.1 Example

An example to upload an e-Invoice using cURL:

curl -H "Content-Type: application/json" -d '{"apiKey":"2B98577D-49DB-4E86-9DF9-F8F6726725AE","eInvoiceData":"aHR0cHM6Ly93d3cueW91dHViZS5jb20vd2F0Y2g/dj1kUXc0dzlXZ1hjUQ==","callbackURL":"https://myapp.com/einvoice/poke"}' https://transfer.onea.be/restv1/einvoice/incoming

Returns:

{"uuid":"AD85DF83-F113-46D7-B07A-28FD943A487A"}

2.2 Status

PATH: /restv1/einvoice/status/{uuid}

METHOD: GET

TYPE: JSON

No API key is needed here; the authentication is implied by the UUID you got when you uploaded the e-Invoice. The UUID is a path parameter in your endpoint.

When your request was successfully processed, the system will return a 200 OK status code with payload status, id. The current status of the document is shown in the status field, and when DONE, the ID field will contain the ScanPRO document ID. All possible status codes are PENDING, DONE, FAILED.

2.2.1 Example

An example to fetch the e-Invoice status using cURL:

curl -H "Content-Type: application/json" "https://transfer.onea.be/restv1/einvoice/status/06aa265c-54b3-4d04-a585-baea0b7d41dc"

Returns when not yet processed:

{"status":"PENDING","id":null}

Returns when processed:

{"status":"DONE","id":"0123456789"}

Returns when failed:

{"status":"FAILURE","id":"0123456789","message":"Error on field 'INVNR' and SUPPCODE': Possible duplicate document with number '789' and supplier/customer 'AAA IC multi (549)' (Document 132, 456)"}

2.3 API Key Validation

Info.png This is a protected endpoint. To access, you'll need to apply at info@onea.be

PATH: /restv1/apikey/{apiKey}

METHOD: GET

TYPE: JSON

The apiKey is a path parameter in your endpoint.

When your request was successfully processed, the system will return a 200 OK status code with payload "apiKey, environment, active".

2.3.1 Example

An example to validate an API key using cURL:

curl -H "Content-Type: application/json" "https://transfer.onea.be/restv1/apikey/8D7832F2-6E10-42ED-8555-C75BF370F878"

Returns when all OK:

{"apiKey":"8D7832F2-6E10-42ED-8555-C75BF370F878","environment":"test-env","active":true}

Returns when no access:

401 Unauthorized

Returns on invalid API key:

404 Not Found