Overview

The REST API provide programmatic access to read and write Ekopost data. Create a new campaign, envelope, scheduele print & distribution, and more. The REST API identifies applications and users using Basic Authentication; responses are available in JSON.

Package for .NET Framework available

If you're using .NET Framework you can download and install our nuget package directly, see the section Tools for more information.

Sandbox - For Developers

During development and testing we recommend using our Sandbox Environment, see the section Sandbox for more information.

Format

The REST API is only using JSON; all requests body should be in JSON and all responses will be JSON. Make sure you set Request.Header.Content-Type to “application/json”.

Sample Request (RAW)

Content-Type: application/json; charset=UTF-8

Encoding

UTF8 is the encoding that should be used at all times.

Authorization

The API uses basic authorization, and all requests must be authorized at all times.

You can use a valid api-key or a base64 encoded string based on your user credentials to build the authorize header value. We recommend that you always use the api-key apprach over the base64 encoded string, as you can create/revoke/reactive/remove api-keys with ease while using the base64 approach your integrations may fail if the password of the used account would ever be changed.

Using an api-key (recommended)

Set the Request.Header.Authorization value to “api-key key”, to get your key you need to generate a new API key after you've signed in to your account, you'll be able to generate and manage your API keys from the account/api section.

Sample Request (RAW)

Authorization: api-key YiuyotGtRNDXik56lgq6
Content-Type: application/json; charset=UTF-8

Using a base64 string

Set the Request.Header.Authorization value to “Basic auth_token”, auth_token should be replaced with a base64 encoded string formatted like: "username:password", where username is your username and password is your password.

Sample Request (RAW)

Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ=
Content-Type: application/json; charset=UTF-8

Error handling

All handled errors will result in bad request (code: 400) and the body will contain an error object for debugging and development purpose with further information how to validate the request, you can see a list of error codes in the section Error under Error code values.

Resources not found will result in not found (code: 404) and any unhandled exception will return internal error (code: 500).

Quick start

To send an envelope you must first create a campaign, then an envelope within that campaign, then create a content (read: upload a document/attachment) within that envelope, once this is done you'll have to close both the campaign and the envelope/s to mark them as ready for production, each envelope in the campaign will be printed & distributed as an individual postal item, the items will be printed & distributed on the campaign output date.

To schedule print and distribution of a envelope – follow these steps (all requests must be authorized).

  • Create a campaign
    Creates an empty campaign in opened state.
  • Create an envelope
    Creates an empty envelope in opened state for the specified campaign.
  • Create content (document)
    Creates a new document and links it to the specified envelope.
  • Create content (attachment)
    Creates a new attachment and links it to the specified envelope.
  • Change the envelope state to closed
    Closes the envelope and marks it as ready for print and distribution. *Note* the campaign must also be closed.
  • Change the campaign state to closed
    Closes the campaign and marks it and all related envelopes as ready for print and distribution.

Limitations

The Content object field named data must be a PDF version 1.4, support for later versions does exist, but printing quality nor result can not be guaranteed without testnig. We always recommend that you send your self a copy of the documents you'll be sending to inspect the result, any deviations should be reported to our support team.

Page margins & reserved areas

Download our content template to learn about our page margins, reserved page areas and where to place your destination adress and return adress for optimal visibility.

Campaign

Campaigns allow for easy management of multiple envelopes and set a date when content should be distributed.

Create campaign

Creates a new campaign with state opened.

POST /campaigns

Request

Parameter Type Description
name String A friendly name to identify the campaign.
output_date Date Date in UTC format representing the date when you would like your envelope printed & distributed.
cost_center String Value representing an internal cost center.

Sample request

Copy
POST /campaigns HTTP/1.1
Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ=
Content-Type: application/json; charset=UTF-8
{
    "name": "Invoice March 2015",
    "output_date": "2015-06-01T12:00:00",
    "cost_center": "Finance Office"
}

Response

Parameter Type Description
id Guid The campaign object's unique id.
name String A friendly name to identify the campaign.
output_date Date Date in UTC format representing the date when you would like your envelope printed & distributed.
cost_center String Value representing an internal cost center.
envelope_count Int Value representing the total number of envelopes in the campaign.
state String State type denominator, see the section State values for valid values.
state_changed_at Date Date in UTC format representing the date when the campaign state was changed.
created_at Date Date in UTC format representing the date when the campaign was created.

Sample response

Copy
HTTP/1.1 200 OK
Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ=
Content-Type: application/json; charset=UTF-8
{
    "id": "4ebeab48-ee03-474f-bc79-c6db082c2bad",
    "name": "Invoice March 2015",
    "output_date": "2015-01-01T12:00:00",
    "cost_center": "Finance Office",
    "envelope_count": 1,
    "state": "opened",
    "state_changed_at": "2015-01-01T12:00:00",
    "created_at": "2015-01-01T12:00:00"
}

Close campaign

Changes a campains state to closed and marks it and all related envelopes as ready for print & distribution.

POST /campaigns/{campaign_id}/close

Request

Parameter Type Description
campaign_id Guid Guid that represents the specified campaign of which to change state to closed.

Sample request

Copy
POST /campaigns/4ebeab48-ee03-474f-bc79-c6db082c2bad/close HTTP/1.1
Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ=
Content-Type: application/json; charset=UTF-8

Response

Sample response

Copy
HTTP/1.1 200 OK

Cancel campaign

Changes a campains state to cancelled and marks it and all related envelopes as not ready for print & distribution.

POST /campaigns/{campaign_id}/cancel

Request

Parameter Type Description
campaign_id Guid Guid that represents the specified campaign of which to change state to cancelled.

Sample request

Copy
POST /campaigns/4ebeab48-ee03-474f-bc79-c6db082c2bad/cancel HTTP/1.1
Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ=
Content-Type: application/json; charset=UTF-8

Response

Sample response

Copy
HTTP/1.1 200 OK

Get campaign

Gets a campaign.

GET /campaigns/{campaign_id}

Request

Parameter Type Description
campaign_id Guid Unique id of the campaign to retrieve.

Sample request

Copy
GET /campaigns/4ebeab48-ee03-474f-bc79-c6db082c2bad HTTP/1.1
Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ=
Content-Type: application/json; charset=UTF-8

Response

Parameter Type Description
id Guid The campaign object's unique id.
name String A friendly name to identify the campaign.
output_date Date Date in UTC format representing the date when you would like your envelope printed & distributed.
cost_center String Value representing an internal cost center.
envelope_count Int Value representing the total number of envelopes in the campaign.
state String State type denominator, see the section State values for valid values.
state_changed_at Date Date in UTC format representing the date when the campaign state was changed.
created_at Date Date in UTC format representing the date when the campaign was created.

Sample response

Copy
HTTP/1.1 200 OK
Content-Type: application/json; charset=UTF-8
{
    "id": "4ebeab48-ee03-474f-bc79-c6db082c2bad",
    "name": "Invoice March 2015",
    "output_date": "2015-01-01T12:00:00",
    "cost_center": "Finance Office",
    "envelope_count": 1,
    "state": "opened",
    "state_changed_at": "2015-01-01T12:00:00",
    "created_at": "2015-01-01T12:00:00" 
}

Get campaigns

Get a list of all campaigns created within a given timespan.

GET /campaigns?start{start}&stop={stop}&name={name}&state={state}

Request

Parameter Type
start Date Optional Date in UTC format representing the start of a timespan.
Remarks: Default value if not specified is today.
stop Date Optional Date in UTC format representing the stop of a timespan.
Remarks: Default value if not specified is tomorrow.
name String Optional Name of the requested campaign.
state String Optional State type denominator, see the section State values for valid values.

Sample request

Copy
GET /campaigns?start={start}&stop={stop}&name={name}&state={state} HTTP/1.1
Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ=
Content-Type: application/json; charset=UTF-8

Response

Parameter Type Description
Array An array of all Campaigns found within the given timespan.

Sample response

The list will be in decending order based on the campaigns created_at date.

Copy
HTTP/1.1 200 OK
Content-Type: application/json; charset=UTF-8
[{
    "id": "4ebeab48-ee03-474f-bc79-c6db082c2bad",
    "name": "Invoice March 2015",
    "output_date": "2015-01-01T12:00:00",
    "cost_center": "Finance Office",
    "envelope_count": 1,
    "state": "opened",
    "state_changed_at": "2015-01-01T12:00:00",
    "created_at": "2015-01-01T12:00:00" 
}]

Envelope

Envelopes represents a single postal item that will be sent to a single recipient, an envelope can contain one document and several attachments.

Create envelope

Creates a new envelope with state opened linked to the specified campaign.

POST /campaigns/{campaign_id}/envelopes

Request

Parameter Type Description
campaign_id Guid Unique id of a campaign within which to create the envelope.
Parameter Type Description
name string A friendly name to identify the envelope.
address Object Address object that represents the destination, see the section Address objects for valid formats.
Remark: a 'null' value in the request will be treated as an address of type postal and the postal address will be extracted from the main document.
postage String Postage type denominator, see the section Postage values for valid values.
plex String Plex type denominator, see the section Plex values for valid values.
color Boolean Print the content in color (CMYK), if set to false the content will be printed in black and white.

Sample request

Copy
POST /campaigns/4ebeab48-ee03-474f-bc79-c6db082c2bad/envelopes HTTP/1.1
Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ=
Content-Type: application/json; charset=UTF-8
{
    "name": "Invoice 9923891",
    "address": null,
    "postage": "priority",
    "plex": "simplex",
    "color": true
}

Response

Parameter Type Description
id Guid The envelope object's unique id.
name string A friendly name to identify the envelope.
address Object Address object that represents the destination, see the section Address objects for valid formats.
Remark: a 'null' value in the request will be treated as an address of type postal and the postal address will be extracted from the main document.
postage String Postage type denominator, see the section Postage values for valid values.
plex String Plex type denominator, see the section Plex values for valid values.
color Boolean Print the content in color (CMYK), if set to false the content will be printed in black and white.
state String State type denominator, see the section State values for valid values.
state_changed_at Date Date in UTC format representing the date when the envelope state was changed.
created_at Date Date in UTC format representing the date when the envelope was created.

Sample response

Copy
HTTP/1.1 200 OK
Content-Type: application/json; charset=UTF-8
{
    "id": "f6aa0f0a-4514-46e5-be2c-539278a58e70",
    "name": "Invoice 9923891",
    "address": {
        "$type": "postal",
        "name": [
            "Company Inc.",
            "c/o John Doe"
        ],
        "street": [
            "Street no. 37"
        ],
        "postal_code": "65421",
        "city": "Gothenburg",
        "country": "SE"
    },
    "postage": "priority",
    "plex": "simplex",
    "color": true,
    "state": "opened",
    "state_changed_at": "2015-01-01T12:00:00",
    "created_at": "2015-01-01T12:00:00"
}

Close evenlope

Changes an envelopes state to closed and marks it as ready for print & distribution.

POST /campaigns/{campaign_id}/envelopes/{envelope_id}/close

Request

Name Type Description
campaign_id Guid Unique id of a campaign.
envelope_id Guid Unique id of an envelope within the campaign.

Sample request

Copy
POST /campaigns/4ebeab48-ee03-474f-bc79-c6db082c2bad/envelopes/f6aa0f0a-4514-46e5-be2c-539278a58e70/close HTTP/1.1
Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ=
Content-Type: application/json; charset=UTF-8

Response

Sample response

Copy
HTTP/1.1 200 OK

Cancel envelope

Changes an envelopes state to cancelled and marks it as not ready for print & distribution.

POST /campaigns/{campaign_id}/envelopes/{envelope_id}/cancel

Request

Name Type Description
campaign_id Guid Unique id of a campaign.
envelope_id Guid Unique id of an envelope within the campaign.

Sample request

Copy
POST /campaigns/4ebeab48-ee03-474f-bc79-c6db082c2bad/envelopes/f6aa0f0a-4514-46e5-be2c-539278a58e70/cancel HTTP/1.1
Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ=
Content-Type: application/json; charset=UTF-8

Response

Sample response

Copy
HTTP/1.1 200 OK

Get envelope

Gets an envelope.

GET /campaigns/{campaign_id}/envelopes/{envelope_id}

Request

Name Type Description
campaign_id Guid Unique id of a campaign.
envelope_id Guid Unique id of an envelope within the campaign.

Sample request

Copy
GET /campaigns/4ebeab48-ee03-474f-bc79-c6db082c2bad/envelopes/f6aa0f0a-4514-46e5-be2c-539278a58e70 HTTP/1.1
Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ=
Content-Type: application/json; charset=UTF-8

Response

Parameter Type Description
id Guid The envelope object's unique id.
name string A friendly name to identify the envelope.
address Object Address object that represents the destination, see the section Address objects for valid formats.
postage String Postage type denominator, see the section Postage values for valid values.
plex String Plex type denominator, see the section Plex values for valid values.
color Boolean Print the content in color (CMYK), if set to false the content will be printed in black and white.
state String State type denominator, see the section State values for valid values.
state_changed_at Date Date in UTC format representing the date when the envelope state was changed.
created_at Date Date in UTC format representing the date when the envelope was created.

Sample response

Copy
HTTP/1.1 200 OK
Content-Type: application/json; charset=UTF-8
{
    "id": "f6aa0f0a-4514-46e5-be2c-539278a58e70",
    "name": "Invoice 9923891",
    "address": {
        "$type": "postal",
        "name": [
            "Company Inc.",
            "c/o John Doe"
        ],
        "street": [
            "Street no. 37"
        ],
        "postal_code": "65421",
        "city": "Gothenburg",
        "country": "SE"
    },
    "postage": "priority",
    "plex": "simplex",
    "color": true,
    "state": "opened",
    "state_changed_at": "2015-01-01T12:00:00",
    "created_at": "2015-01-01T12:00:00"
}

Get envelopes

Gets a list of all envelopes within a campaign.

GET /campaigns/{campaign_id}/envelopes?name={name}&state={state}

Request

Name Type Description
campaign_id Guid Unique id of a campaign.
name String Optional Name of the envelope or envelopes.
state String Optional State type denominator, see the section State values for valid values.

Sample request

Copy
GET /campaigns/4ebeab48-ee03-474f-bc79-c6db082c2bad/envelopes?name={name}&state={state} HTTP/1.1
Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ=
Content-Type: application/json; charset=UTF-8

Response

Parameter Type Description
Array An array of all Envelopes within the campaign.

Sample response

Copy
HTTP/1.1 200 OK
Content-Type: application/json; charset=UTF-8
[{
    "id": "f6aa0f0a-4514-46e5-be2c-539278a58e70",
    "name": "Invoice 9923891",
    "address": {
        "$type": "postal",
        "name": [
            "Company Inc.",
            "c/o John Doe"
        ],
        "street": [
            "Street no. 37"
        ],
        "postal_code": "65421",
        "city": "Gothenburg",
        "country": "SE"
    },
    "postage": "priority",
    "plex": "simplex",
    "color": true,
    "state": "opened",
    "state_changed_at": "2015-01-01T12:00:00"
    "created_at": "2015-01-01T12:00:00"
}]

Content

Content can either be a document or an attachment linked to an envelope, an envelope can only have one document linked to it, but several attachments, please read the section Limitation for further information.

Create content

Creates a content either as a document or attachment linked to the specified envelope, only one document can be linked to an envelope.

POST /campaigns/{campaign_id}/envelopes/{envelope_id}/content

Request

Parameter Type Description
campaign_id Guid Unique id of a campaign within which the envelope exists.
envelope_id Guid Unique id of an envelope to add the content to.
Parameter Type Description
data String The original file's data as a base64encoded string.
mime String The original file's mime type.
length Int The original file's size in bytes.
type String Content type denominator, see the Type values section for valid values.
return_address Boolean Optional Set as true to add a return address on the upper left corner of the letter. (The address that will show is the return address on your account.)
address Object Optional Address object that represents postal destination of returned letters, see the section Address objects. Object (postal) is the valid object.
Remark: For this address to be used as a return address on the letter, return_address must also have the value 'true'

Sample request

Copy
POST /campaigns/4ebeab48-ee03-474f-bc79-c6db082c2bad/envelopes/f6aa0f0a-4514-46e5-be2c-539278a58e70/content HTTP/1.1
Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ=
Content-Type: application/json; charset=UTF-8
{
    "data": "YW55IGNhcm5hbCBwbGVhcw==",
    "mime": "application/pdf",
    "length": 1024,
    "type": "document"
}

Sample request with return address

Copy

POST /campaigns/4ebeab48-ee03-474f-bc79-c6db082c2bad/envelopes/f6aa0f0a-4514-46e5-be2c-539278a58e70/content HTTP/1.1
Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ=
Content-Type: application/json; charset=UTF-8
{
    "data": "YW55IGNhcm5hbCBwbGVhcw==",
    "mime": "application/pdf",
    "length": 1024,
    "type": "document",
    "return_address" : "true",
    "address": null (See Address objects postal for exampel when not null)
}

Response

Parameter Type Description
id Guid The content object's unique id.
mime String The original file's mime type.
length Int The original file's size in bytes.
type String Content type denominator, see the Type values section for valid values.
created_at Date Date in UTC format representing the date when the content was created.
return_address Boolean Value to show if return address was triggered.

Sample response

Copy
HTTP/1.1 200 OK
Content-Type: application/json; charset=UTF-8
{
    "id": "d2c5fedd-0749-482c-94b9-7f13bd442a04",
    "mime": "application/pdf",
    "length": 1024,
    "type": "document",             
    "return_address" : "false",
    "created_at": "2015-01-01T12:00:00"
}

Get content

Gets an envelope content.

GET /campaigns/{campaign_id}/envelopes/{envelope_id}/content/{content_id}

Request

Name Type Description
campaign_id Guid Unique id of a campaign.
envelope_id Guid Unique id of an envelope within the campaign.
content_id Guid Unique id of a content within the envelope.

Sample request

Copy
POST /campaigns/4ebeab48-ee03-474f-bc79-c6db082c2bad/envelopes/f6aa0f0a-4514-46e5-be2c-539278a58e70/content/d2c5fedd-0749-482c-94b9-7f13bd442a04 HTTP/1.1
Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ=
Content-Type: application/json; charset=UTF-8

Response

Name Type Description
id Guid The content object's unique id.
mime String The original file's mime type.
length Int The original file's size in bytes.
type String Content type denominator, see the Type values section for valid values.
created_at Date Date in UTC format representing the date when the content was created.

Sample response

Copy
HTTP/1.1 200 OK
Content-Type: application/json; charset=UTF-8
{
    "id": "d2c5fedd-0749-482c-94b9-7f13bd442a04",
    "mime": "application/pdf",
    "length": 1024,
    "type": "document",
    "created_at": "2015-01-01T12:00:00"
}

Reachable

Through a reachable request you can figure out if a recipient is reachable or not and the true recipient address.

Check reachable status

Returns information if the recipient is reachable and the true recipient address.
Remarks: Returns 404 if the recipient is not reachable.

POST /reachable/{type}

Request

Parameter Type Description
type String The type of address to check reachable status for, valid values are 'einbox' and 'ebank'.
Parameter Type Description
recipient String The recipient to check reachable status for.

Sample request

Copy
GET /reachable/ebank/800101xxxx HTTP/1.1
Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ=
Content-Type: application/json; charset=UTF-8
{
    "recipient": "800101xxxx",
}

Response

Parameter Type Description
recipient String Will return the true recipient address for the address checked.
Remark:The returned recipient address should be used as recipient in the address object if it's different from the request value.

Sample response

Copy
HTTP/1.1 200 OK
Content-Type: application/json; charset=UTF-8
{
    "recipient": "800101xxxx.BNK.SE",
}
Copy
HTTP/1.1 404 NOT FOUND
Content-Type: application/json; charset=UTF-8

Objects

This section describes all response objects within the REST API.

Campaign

Representation of a campaign that will be posted.

Object

Parameter Type Description
id Guid The campaign object's unique id.
name String A friendly name to identify the campaign.
output_date Date Date in UTC format representing the date when you would like your envelope printed & distributed.
cost_center String Value representing an internal cost center.
envelope_count Int Value representing the total number of envelopes in the campaign.
state String State type denominator, see the section State values for valid values..
state_changed_at Date Date in UTC format representing the date when the campaign state was changed.
created_at Date Date in UTC format representing the date when the campaign was created.
{
    "id": "4ebeab48-ee03-474f-bc79-c6db082c2bad",
    "name": "Invoice March 2015",
    "output_date": "2015-01-01T12:00:00",
    "cost_center": "Finance Office",
    "envelope_count": 1,
    "state": "opened",
    "state_changed_at": "2015-01-01T12:00:00",
    "created_at": "2015-01-01T12:00:00"
}

State values

String Description
opened The campaign is opened, you can add envelope, modify or change state to cancelled.
closed The campaign is marked as ready for production and can not be modified.
transferred The campaign and all linked envelopes has been transferred to our production facility.
completed The campaign and all linked envelopes has been printed and posted.
cancelled The campaign has been closed and all linked envelopes will not be printed or distributed.
failed The campaign could not be produced in our facility, contact our customer service for further details.

Envelope

Representation of an envelope that will be posted.

Object

Parameter Type Description
id Guid The envelope object's unique id.
name string A friendly name to identify the envelope.
address Object Address object that represents the destination, see the section Address objects for valid formats.
Remark: a 'null' value in the request will be treated as an address of type postal and the postal address will be extracted from the main document.
postage String Postage type denominator, see the section Postage values for valid values.
plex String Plex type denominator, see the section Plex values for valid values.
color Boolean Print the content in color (CMYK), if set to false the content will be printed in black and white.
state String State type denominator, see the section State values for valid values.
state_changed_at Date Date in UTC format representing the date when the envelope state was changed.
created_at Date Date in UTC format representing the date when the envelope was created.
{
    "id": "f6aa0f0a-4514-46e5-be2c-539278a58e70",
    "name": "Invoice 9923891",
    "address": {
        "$type": "postal",
        "name": [
            "Company Inc.",
            "c/o John Doe"
        ],
        "street": [
            "Street no. 37"
        ],
        "postal_code": "65421",
        "city": "Gothenburg",
        "country": "SE"
    },
    "postage": "priority",
    "plex": "simplex",
    "color": true,
    "state": "opened",
    "state_changed_at": "2015-01-01T12:00:00",
    "created_at": "2015-01-01T12:00:00"
}

Postage values

Value Description
priority Your content will be delivered within one working day after it's been printed and posted.
economy Your content will be delivered within four working days after it's been printed and posted.

Plex values

Value Description
simplex We will only print on the front of each paper sheet.
duplex We will print on both the front and back of each paper sheet.

State values

Value Description
opened The envelope is in opened state, you can add content, modify or cancel the envelope.
closed The envelope is in closed state, it's marked as ready for print & distribution.
transferred The envelope has been transferred to our production facility, and can no longer be modified or cancelled.
printed The envelope has been printed in our production facility.
posted The envelope has been posted.
cancelled The envelope has been cancelled, and will not be printed or distributed.
failed The envelope could not be produced in our facility, contact our customer service for further information.

Address

There are three valid types of addresses; postal, einvoice, email.

Object (postal)

The envelopes content will be printed and will be sent with regual postal mail.

Parameter Type Description
$type String Denominator for the address type, should always be set to 'postal'.
Remark: this parameter must come first in the json object.
name String[] The recipient's name, each string in the array is considered to be a address line.
street String[] The recipient's street name, each string in the array is considered to be a address line.
postal_code String The recipient's postal/zip code.
city String The recipient's city name.
country String The recipient's country name or country code as a ISO 3166-1 encoded alpha-2 code. See an official list of country codes.
{
    "$type": "postal",
    "name": [
        "Company Inc.",
        "c/o John Doe"
    ],
    "street": [
        "Street no. 37"
    ],
    "postal_code": "65421",
    "city": "Gothenburg",
    "country": "SE"
}

Object (email)

The envelopes content will be attached to an email and sent to the specified recipient.

Parameter Type Description
$type String Denominator for the address type, should always be set to 'email'.
Remark: this parameter must come first in the json object.
subject String The value will be set as the email's subject field.
recipient String The recipient's email adress, to where the contents of the envelope will be sent.
{
    "$type": "email",
    "subject": "Invoice 9923891",
    "recipient": "johndoe@johndoe.com"
}

Object (einbox)

The content will be sent to a digital inbox (einbox) owned by the recipient, if the einbox doesn't exist the envelope will be printed and posted instead.

Parameter Type Description
$type String Denominator for the address type, should always be set to 'einbox'.
Remark: this parameter must come first in the json object.
recipient String The recipient of the einbox's social security number, to where the contents of the envelope will be sent.
template String The id of a predefinied ekopost template. The stored subject and content of the template will be used instead of any subject/content specified in the request.
subject String The value will be displayed as subject in the recipient's e-inbox if supported. Remarks: if a template has been specified this value will be ignored and the stored subject of the template will be used instead.
content String The specified content will be displayed as html/text message in the recipients e-inbox if supported. Remarks: if a template has been specified this value will be ignored and the stored content of the template will be used instead.
meta String The specified content will be be forward to the selected einbox service.
Remarks: Documentation will very dependent on service.
  • Kivra - supports metadata. As a minimum a valid “ssn” or “vat_number” is required. Note that Kivra will reject Content using both​ “ssn” and “vat_number” in the same metadata as this is ambiguous.
    Detailed parameter documentation
    {
        {
            "vat_number" : "​SE556840226601​",
            "ssn": "191212121414",
            "subject": "Välkommen till Kivra, din digitala brevlåda",
            "files": [
                {
                  "name": "filename.pdf",
                  "data": "PDF_DATA(Base64-encoded)",
                  "content_type": "application/pdf"
                }
              ]
            "context":{
                "invoice": {
                    "payment": {
                        "payable": true,
                        "status": "unpaid",
                        "currency": "SEK",
                        "due_date": "2014-08-20",
                        "total_owed": "123.49",
                        "type": "SE_OCR",
                        "method": "1",
                        "account": "1234-4321",
                        "reference": "OCR_NUMBER"
                    },
                    "invoice_reference": "TENANT_REFERENCE"
            }
        }
    }
    
    
{
    "$type": "einbox",
    "subject": "Invoice 9923891",
    "recipient": "800101xxxx"
}

Object (einvoice)

The envelopes content will be transfered electronically to the recipient.

Parameter Type Description
$type String Denominator for the address type, should always be set to 'einvoice'.
Remark: this parameter must come first in the json object.
format String Format type denominator, see the section Format values for valid values.
sender String Identifier of the sender, this is usually the sender's registration number.
sender_type String Identifier type denominator, see the section Identifier type values for valid values.
recipient String Identifier of the recipient, this is usually the recipient's registration number.
recipient_type String Identifier type denominator, see the section Identifier type values for valid values.
intermediator String Intermediator type denominator, see the section Intermediator values for valid values.
Remark: If the recipient is using Ekopost to receive eletronic documents or the intermediator is not found or unkwon, set the value to 'null'.
{
    "$type": "einvoice",
    "format": "svefaktura-1.0"
    "sender": "556838-4118",
    "sender_type": "SE.REGNO",
    "recipient": "556838-4118",
    "recipient_type": "SE.REGNO"
    "intermediator": null
}

Format values

Value Description
svefaktura-1.0 This represents version 1.0 of svefaktura.
svefaktura-2.0-invoice This represents version 2.0 of svefaktura, type invoice.
svefaktura-2.0-creditnote This represents version 2.0 of svefaktura, type creditnote.

Identifier values

Value Description
SE.REGNO This represents a swedish company registration number, format e.g. "556838-4118".
SE.SSNNO This represents a swedish personal social security number, format e.g. "YYMMDD-XXXX".
GS1.GLN This represents a global location number (GLN) based on the GS1 general specifications.

Intermediator values

Value Description
peppol Pan-European Public Procurement Online.

Object (ebank)

The envelopes content will be transfered electronically to the recipients internet bank.

Parameter Type Description
$type String Denominator for the address type, should always be set to 'ebank'.
Remark: this parameter must come first in the json object.
recipient String An identifier (FMI) of the recipient, the identifier is usually provided by the bank or through a lookup service.
customer_number String External identifier of the customer, this is usually a number stored in the senders system.
customer_name String Name of the customer.
invoice_number String The external invoice number.
reference_type String The external reference type used as a reference when paying the invoice, type can be either 'ocr' or 'message'.
reference_value String The external reference value used as a reference when paying the invoice.
giro_number String The giro account number of the payment recipient.
autogiro Boolean Set to true if the invoice is payed through autogiro.
Remark: Setting this to true will disable manual payment of the invoice in the internet bank.
amount String The total amount of the invoice.
invoice_date String Date when the invoice was issued.
due_date String Date when the invoice payment is due.
{
    "$type": "ebank",
    "recipient": "5568384118.BNK.SE",
    "customer_number": "556838-4118",
    "customer_name": "No Ink AB",
    "invoice_number": "556838",
    "reference_type": "ocr",
    "reference_value": "0000556838411800",
    "giro_number": "5568-3841",
    "autogiro": true,
    "amount": 499.99,
    "invoice_date": "2015-01-01T00:00:00",
    "due_date": "2015-01-31T00:00:00"
}

Content

Representation of a document or an attachment that will be printed.

Object

Parameter Type Description
id Guid The content object's unique id.
mime String The original file's mime type.
length Int The original file's size in bytes.
type String Content type denominator, see the Type values section for valid values.
created_at Date Date in UTC format representing the date when the content was created.
{
    "id": 100,
    "mime": "application/pdf",
    "length": 1024,
    "type": "document",
    "created_at": "2015-01-01T12:00:00"
}

Type values

Value Description
document The object intance represents the main document.
attachment The object intance represents an attachment.
markup The object intance represents a xml markup.

Error

Bad requests with http response code 400 does contains an error object with futher information about the bad request.

Object

Parameter Type Description
error_code String Code that represents the error that occured.
error_message String Description about what error occured.
developer_message String Further description about the error for developers.
{
    "error_code": "0",
    "error_message": "Invalid basic authentication token.",
	"developer_message": "Please verify that the account is activated and the username and password are valid."
}

Error code values

Value Description
0 Invalid basic authentication token.
100A The envelope must contain atleast one (1) document before being closed.
100B The envelope must contain atleast one (1) markup before being closed.
101 A campaign must contain atleast one (1) envelope before being closed.
102 All envelopes inside a campaign must be closed before closing the campaign.
103 An envelope may only contain one (1) document.
104 An envelope may only contain content with mime of 'application/pdf'.
105 Could not extract or identify a postal address in the envelopes main documents.
106 Campaign was not found.
107 Could not open the main document content or find any pages.
108 An envelope may only contain content of type 'attachment' with mime set to 'application/pdf'.
109 An envelope may only contain content of type 'markup' with mime set to 'application/xml'.
110 An envelope may only contain one (1) markup.
111 Envelope was not found.
112 Specified country is not a valid ISO 3166-1 encoded alpha-2 code.
113 You have exceeded your credit limit for the month, please contact our customer service to adjust your credit limit.
114 The searchparams is null.
115 The searchparams is invalid.
116 The timespan is invalid.

Tools

Package for .NET Framework

Ekopost is quick and easy to integrate in a .NET environment using our nuget package, the package uses a fluent interface to schedule print & production.

Installation

Copy
PM >  Install-Package Ekopost

Usage

Copy
using Ekopost;

/* Examples coming soon */

Sandbox

Set up Sandbox for testing

The url for connecting to our sandbox environment is http://api.sandbox.ekopost.se

Remarks:
Sandbox do not use https!
Nothing that uploaded to sandbox will be sent to end customers.

  1. Cretae a sandbox user. Click here to create.

  2. If you already have created a sanbox-user, Click here to login

  3. When you have created your sandbox account, you will automatically be signed in and you can immediately manually start uploading letter for testing or start using our API (http://api.sandbox.ekopost.se) with your user information that has been sent to your e-mail you entered when registering.