List all accounts

Retrieves a list of accounts. The accounts are returned sorted by account number with the lowest number appearing first.

Examples

Request

curl -X GET "https://api.fortnox.se/3/accounts" \
     -H "Access-Token: 61cf63ae-4ab9-4a95-9db5-753781c4f41f" \
     -H "Content-Type: application/json" \
     -H "Client-Secret: 3Er4kHXZTJ" \
     -H "Accept: application/json" \
     -m 30 \
     -v \

Response

{
  "MetaInformation": {
    "@TotalResources": 1210,
    "@TotalPages": 13,
    "@CurrentPage": 1
  },
  "Accounts": [
    {
      "@url": "https://api.fortnox.se/3/accounts/1010?financialyear=1",
      "Active": false,
      "Description": "Balanserade utgifter",
      "Number": 1010,
      "SRU": 7201,
      "Year": 1
    },

    [...]

    {
      "@url": "https://api.fortnox.se/3/accounts/1348?financialyear=1",
      "Active": false,
      "Description": "Ackumulerade nedskrivningar av långfristiga fordringar hos intresseföretag",
      "Number": 1348,
      "SRU": 7232,
      "Year": 1
    }
  ]
}

Using Guzzle

Request

// Include Guzzle. If using Composer:
// require 'vendor/autoload.php';

use GuzzleHttp\Client;
use GuzzleHttp\Exception\RequestException;

function send_request() {
    // Accounts (GET https://api.fortnox.se/3/accounts)

    $client = new Client();
    $request = $client->createRequest('GET', 'https://api.fortnox.se/3/accounts');

    try {
        $request->addHeaders([
            'Access-Token'=>'61cf63ae-4ab9-4a95-9db5-753781c4f41f',
            'Client-Secret'=>'3Er4kHXZTJ',
            'Content-Type'=>'application/json',
            'Accept'=>'application/json',
        ]);

        $response = $client->send($request);
        echo "Response HTTP : " . $response->getStatusCode();
    }
    catch (RequestException $e) {
        echo "HTTP Request failed\n";
        echo $e->getRequest();
        if ($e->hasResponse()) {
            echo $e->getResponse();
        }
    }
}

Response

{
  "MetaInformation": {
    "@TotalResources": 1210,
    "@TotalPages": 13,
    "@CurrentPage": 1
  },
  "Accounts": [
    {
      "@url": "https://api.fortnox.se/3/accounts/1010?financialyear=1",
      "Active": false,
      "Description": "Balanserade utgifter",
      "Number": 1010,
      "SRU": 7201,
      "Year": 1
    },

    [...]

    {
      "@url": "https://api.fortnox.se/3/accounts/1348?financialyear=1",
      "Active": false,
      "Description": "Ackumulerade nedskrivningar av långfristiga fordringar hos intresseföretag",
      "Number": 1348,
      "SRU": 7232,
      "Year": 1
    }
  ]
}

Request

require 'uri'
require 'net/https'

# Request: Accounts (https://api.fortnox.se/3/accounts)

uri = URI.parse("https://api.fortnox.se/3/accounts")
http = Net::HTTP.new(uri.host, uri.port)
http.read_timeout = 30
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_PEER
request = Net::HTTP::Get.new(uri.request_uri)

# Headers

request["Access-Token"] = "61cf63ae-4ab9-4a95-9db5-753781c4f41f"
request["Content-Type"] = "application/json"
request["Client-Secret"] = "3Er4kHXZTJ"
request["Accept"] = "application/json"

# Send synchronously

response = http.request(request)

Response

{
  "MetaInformation": {
    "@TotalResources": 1210,
    "@TotalPages": 13,
    "@CurrentPage": 1
  },
  "Accounts": [
    {
      "@url": "https://api.fortnox.se/3/accounts/1010?financialyear=1",
      "Active": false,
      "Description": "Balanserade utgifter",
      "Number": 1010,
      "SRU": 7201,
      "Year": 1
    },

    [...]

    {
      "@url": "https://api.fortnox.se/3/accounts/1348?financialyear=1",
      "Active": false,
      "Description": "Ackumulerade nedskrivningar av långfristiga fordringar hos intresseföretag",
      "Number": 1348,
      "SRU": 7232,
      "Year": 1
    }
  ]
}

Request

import httplib

# Request: Accounts (https://api.fortnox.se/3/accounts)

connection = httplib.HTTPSConnection('api.fortnox.se', 443, timeout = 30)

# Headers

headers = {"Access-Token":"61cf63ae-4ab9-4a95-9db5-753781c4f41f",
           "Content-Type":"application/json",
           "Client-Secret":"3Er4kHXZTJ",
           "Accept":"application/json"}

# Send synchronously

connection.request('GET', '/3/accounts', None, headers)
try:
	response = connection.getresponse()
	content = response.read()
	# Success
	print('Response status ' + str(response.status))
except httplib.HTTPException, e:
	# Exception
	print('Exception during request')

Response

{
  "MetaInformation": {
    "@TotalResources": 1210,
    "@TotalPages": 13,
    "@CurrentPage": 1
  },
  "Accounts": [
    {
      "@url": "https://api.fortnox.se/3/accounts/1010?financialyear=1",
      "Active": false,
      "Description": "Balanserade utgifter",
      "Number": 1010,
      "SRU": 7201,
      "Year": 1
    },

    [...]

    {
      "@url": "https://api.fortnox.se/3/accounts/1348?financialyear=1",
      "Active": false,
      "Description": "Ackumulerade nedskrivningar av långfristiga fordringar hos intresseföretag",
      "Number": 1348,
      "SRU": 7232,
      "Year": 1
    }
  ]
}

Using our .NET SDK

Request

AccountConnector connector = new AccountConnector();
Accounts result = connector.Find();

Retrieve an account

Retrieves the details of an account. You need to supply the unique account number that was returned when the account was created or retrieved from the list of accounts.

Examples

Request

curl -X GET "https://api.fortnox.se/3/accounts/1010" \
     -H "Content-Type: application/json" \
     -H "Access-Token: 61cf63ae-4ab9-4a95-9db5-753781c4f41f" \
     -H "Accept: application/json" \
     -H "Client-Secret: 3Er4kHXZTJ" \
     -m 30 \
     -v \

Response

{
  "Account": {
    "@url": "https://api.fortnox.se/3/accounts/1010?financialyear=1",
    "Active": false,
    "BalanceBroughtForward": 0,
    "BalanceCarriedForward": 0,
    "CostCenter": "",
    "CostCenterSettings": "ALLOWED",
    "Description": "Balanserade utgifter",
    "Number": 1010,
    "Project": "",
    "ProjectSettings": "ALLOWED",
    "SRU": 7201,
    "TransactionInformation": "",
    "TransactionInformationSettings": "ALLOWED",
    "VATCode": null,
    "Year": 1
  }
}

Using Guzzle

Request

// Include Guzzle. If using Composer:
// require 'vendor/autoload.php';

use GuzzleHttp\Client;
use GuzzleHttp\Exception\RequestException;

function send_request() {
    // Account (GET https://api.fortnox.se/3/accounts/1010)

    $client = new Client();
    $request = $client->createRequest('GET', 'https://api.fortnox.se/3/accounts/1010');

    try {
        $request->addHeaders([
            'Access-Token'=>'61cf63ae-4ab9-4a95-9db5-753781c4f41f',
            'Client-Secret'=>'3Er4kHXZTJ',
            'Content-Type'=>'application/json',
            'Accept'=>'application/json',
        ]);

        $response = $client->send($request);
        echo "Response HTTP : " . $response->getStatusCode();
    }
    catch (RequestException $e) {
        echo "HTTP Request failed\n";
        echo $e->getRequest();
        if ($e->hasResponse()) {
            echo $e->getResponse();
        }
    }
}

Response

{
  "Account": {
    "@url": "https://api.fortnox.se/3/accounts/1010?financialyear=1",
    "Active": false,
    "BalanceBroughtForward": 0,
    "BalanceCarriedForward": 0,
    "CostCenter": "",
    "CostCenterSettings": "ALLOWED",
    "Description": "Balanserade utgifter",
    "Number": 1010,
    "Project": 0,
    "ProjectSettings": "ALLOWED",
    "SRU": 7201,
    "TransactionInformation": "",
    "TransactionInformationSettings": "ALLOWED",
    "VATCode": null,
    "Year": 1
  }
}

Request

require 'uri'
require 'net/https'

# Request: Account (https://api.fortnox.se/3/accounts/1010)

uri = URI.parse("https://api.fortnox.se/3/accounts/1010")
http = Net::HTTP.new(uri.host, uri.port)
http.read_timeout = 30
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_PEER
request = Net::HTTP::Get.new(uri.request_uri)

# Headers

request["Content-Type"] = "application/json"
request["Access-Token"] = "61cf63ae-4ab9-4a95-9db5-753781c4f41f"
request["Accept"] = "application/json"
request["Client-Secret"] = "3Er4kHXZTJ"

# Send synchronously

response = http.request(request)

Response

{
  "Account": {
    "@url": "https://api.fortnox.se/3/accounts/1010?financialyear=1",
    "Active": false,
    "BalanceBroughtForward": 0,
    "BalanceCarriedForward": 0,
    "CostCenter": "",
    "CostCenterSettings": "ALLOWED",
    "Description": "Balanserade utgifter",
    "Number": 1010,
    "Project": 0,
    "ProjectSettings": "ALLOWED",
    "SRU": 7201,
    "TransactionInformation": "",
    "TransactionInformationSettings": "ALLOWED",
    "VATCode": null,
    "Year": 1
  }
}

Request

import httplib

# Request: Account (https://api.fortnox.se/3/accounts/1010)

connection = httplib.HTTPSConnection('api.fortnox.se', 443, timeout = 30)

# Headers

headers = {"Content-Type":"application/json",
           "Access-Token":"61cf63ae-4ab9-4a95-9db5-753781c4f41f",
           "Accept":"application/json",
           "Client-Secret":"3Er4kHXZTJ"}

# Send synchronously

connection.request('GET', '/3/accounts/1010', None, headers)
try:
	response = connection.getresponse()
	content = response.read()
	# Success
	print('Response status ' + str(response.status))
except httplib.HTTPException, e:
	# Exception
	print('Exception during request')

Response

{
  "Account": {
    "@url": "https://api.fortnox.se/3/accounts/1010?financialyear=1",
    "Active": false,
    "BalanceBroughtForward": 0,
    "BalanceCarriedForward": 0,
    "CostCenter": "",
    "CostCenterSettings": "ALLOWED",
    "Description": "Balanserade utgifter",
    "Number": 1010,
    "Project": 0,
    "ProjectSettings": "ALLOWED",
    "SRU": 7201,
    "TransactionInformation": "",
    "TransactionInformationSettings": "ALLOWED",
    "VATCode": null,
    "Year": 1
  }
}

Using our .NET SDK

Request

AccountConnector connector = new AccountConnector();
Account result = connector.Get("1010");

Create an account

The created account will be returned if everything succeeded, if there was any problems an error will be returned.

Examples

Request

curl -X "POST" "https://api.fortnox.se/3/accounts" \
     -H "Access-Token: 61cf63ae-4ab9-4a95-9db5-753781c4f41f" \
     -H "Client-Secret: 3Er4kHXZTJ" \
     -H "Content-Type: application/json" \
     -H "Accept: application/json" \
     -d $'{
  "Account": {
    "Description": "Goodwill",
    "Number": 1070
  }
}'

Response

{
    "Account": {
        "@url": "https://api.fortnox.se/3/accounts/1070?financialyear=1",
        "Active": true,
        "BalanceBroughtForward": 0,
        "BalanceCarriedForward": 0,
        "CostCenter": "",
        "CostCenterSettings": "ALLOWED",
        "Description": "Goodwill",
        "Number": 1070,
        "Project": "",
        "ProjectSettings": "ALLOWED",
        "SRU": 0,
        "TransactionInformation": "",
        "TransactionInformationSettings": "ALLOWED",
        "VATCode": null,
        "Year": 1
    }
}

Using Guzzle

Request

// Include Guzzle. If using Composer:
// require 'vendor/autoload.php';

use GuzzleHttp\Client;
use GuzzleHttp\Post\PostBody;
use GuzzleHttp\Stream\StreamInterface;
use GuzzleHttp\Exception\RequestException;

function send_request() {
    // Accounts (POST https://api.fortnox.se/3/accounts)

    $client = new Client();
    $request = $client->createRequest('POST', 'https://api.fortnox.se/3/accounts');
    $postBody = $request->getBody();

    try {
        $request->addHeaders([
            'Access-Token'=>'61cf63ae-4ab9-4a95-9db5-753781c4f41f',
            'Client-Secret'=>'3Er4kHXZTJ',
            'Content-Type'=>'application/json',
            'Accept'=>'application/json',
        ]);
        $body = [
            "Account" => [
                "Number" => 6666,
                "Description" => "Goodwill"
            ]
        ];
        $request->setBody(GuzzleHttp\Stream\Stream::factory(json_encode($body)));

        $response = $client->send($request);
        echo "Response HTTP : " . $response->getStatusCode();
    }
    catch (RequestException $e) {
        echo "HTTP Request failed\n";
        echo $e->getRequest();
        if ($e->hasResponse()) {
            echo $e->getResponse();
        }
    }
}

Response

{
    "Account": {
        "@url": "https://api.fortnox.se/3/accounts/1070?financialyear=1",
        "Active": true,
        "BalanceBroughtForward": 0,
        "BalanceCarriedForward": 0,
        "CostCenter": "",
        "CostCenterSettings": "ALLOWED",
        "Description": "Goodwill",
        "Number": 1070,
        "Project": 0,
        "ProjectSettings": "ALLOWED",
        "SRU": 0,
        "TransactionInformation": "",
        "TransactionInformationSettings": "ALLOWED",
        "VATCode": null,
        "Year": 1
    }
}

Request

require 'net/http'
require 'json'

def send_request
    # Accounts (POST https://api.fortnox.se/3/accounts)

    begin
        uri = URI('https://api.fortnox.se/3/accounts')

        http = Net::HTTP.new(uri.host, uri.port)
        req =  Net::HTTP::Post.new(uri)

        req.add_field "Access-Token, 61cf63ae-4ab9-4a95-9db5-753781c4f41f"
        req.add_field "Client-Secret, 3Er4kHXZTJ"
        req.add_field "Content-Type, application/json"
        req.add_field "Accept, application/json"

        data = JSON.dump({
            "Account": {
                "Number": 6666,
                "Description": "Goodwill"
            }
        })
        req.body = data

        res = http.request(req)
        puts "Response HTTP #{res.code}"
    rescue Exception => e
        puts "HTTP Request failed (#{e.message})"
    end
end

Response

{
    "Account": {
        "@url": "https://api.fortnox.se/3/accounts/1070?financialyear=1",
        "Active": true,
        "BalanceBroughtForward": 0,
        "BalanceCarriedForward": 0,
        "CostCenter": "",
        "CostCenterSettings": "ALLOWED",
        "Description": "Goodwill",
        "Number": 1070,
        "Project": 0,
        "ProjectSettings": "ALLOWED",
        "SRU": 0,
        "TransactionInformation": "",
        "TransactionInformationSettings": "ALLOWED",
        "VATCode": null,
        "Year": 1
    }
}

Request

import requests
import json

def send_request():
    # Accounts (POST https://api.fortnox.se/3/accounts)

    try:
        r = requests.post(
            url="https://api.fortnox.se/3/accounts",
            headers = {
                "Access-Token":"61cf63ae-4ab9-4a95-9db5-753781c4f41f",
                "Client-Secret":"3Er4kHXZTJ",
                "Content-Type":"application/json",
                "Accept":"application/json",
            },
            data = json.dumps({
                "Account": {
                    "Number": 6666,
                    "Description": "Goodwill"
                }
            })
        )
        print('Response HTTP {status_code}'.format(status_code=r.status_code))
    except requests.exceptions.RequestException as e:
        print('HTTP Request failed')

Response

{
    "Account": {
        "@url": "https://api.fortnox.se/3/accounts/1070?financialyear=1",
        "Active": true,
        "BalanceBroughtForward": 0,
        "BalanceCarriedForward": 0,
        "CostCenter": "",
        "CostCenterSettings": "ALLOWED",
        "Description": "Goodwill",
        "Number": 1070,
        "Project": 0,
        "ProjectSettings": "ALLOWED",
        "SRU": 0,
        "TransactionInformation": "",
        "TransactionInformationSettings": "ALLOWED",
        "VATCode": null,
        "Year": 1
    }
}

Using our .NET SDK

Request

AccountConnector connector = new AccountConnector();
Account result = connector.Create(new Account() { Number = "8888", Description = "Goodwill" });

Update an account

Updates the specified account with the values provided in the properties. Any property not provided will be left unchanged.

Note that even though the account number is writeable you can’t change the number of an existing account.

Examples

Request

curl -X "PUT" "https://api.fortnox.se/3/accounts/1070" \
     -H "Access-Token: 61cf63ae-4ab9-4a95-9db5-753781c4f41f" \
     -H "Client-Secret: 3Er4kHXZTJ" \
     -H "Content-Type: application/json" \
     -H "Accept: application/json" \
     -d $'{
  "Account": {
    "Number": 1070,
    "Active": false
  }
}'

Response

{
    "Account": {
        "@url": "https://api.fortnox.se/3/accounts/1070?financialyear=1",
        "Active": false,
        "BalanceBroughtForward": 0,
        "BalanceCarriedForward": 0,
        "CostCenter": "",
        "CostCenterSettings": "ALLOWED",
        "Description": "Goodwill",
        "Number": 1070,
        "Project": "",
        "ProjectSettings": "ALLOWED",
        "SRU": 7201,
        "TransactionInformation": "",
        "TransactionInformationSettings": "ALLOWED",
        "VATCode": null,
        "Year": 1
    }
}

Using Guzzle

Request

// Include Guzzle. If using Composer:
// require 'vendor/autoload.php';

use GuzzleHttp\Client;
use GuzzleHttp\Post\PostBody;
use GuzzleHttp\Stream\StreamInterface;
use GuzzleHttp\Exception\RequestException;

function send_request() {
    // Account (PUT https://api.fortnox.se/3/accounts/1070)

    $client = new Client();
    $request = $client->createRequest('PUT', 'https://api.fortnox.se/3/accounts/1070');
    $postBody = $request->getBody();

    try {
        $request->addHeaders([
            'Access-Token'=>'61cf63ae-4ab9-4a95-9db5-753781c4f41f',
            'Client-Secret'=>'3Er4kHXZTJ',
            'Content-Type'=>'application/json',
            'Accept'=>'application/json',
        ]);
        $body = [
            "Account" => [
                "Active" => false,
                "Number" => 1070
            ]
        ];
        $request->setBody(GuzzleHttp\Stream\Stream::factory(json_encode($body)));

        $response = $client->send($request);
        echo "Response HTTP : " . $response->getStatusCode();
    }
    catch (RequestException $e) {
        echo "HTTP Request failed\n";
        echo $e->getRequest();
        if ($e->hasResponse()) {
            echo $e->getResponse();
        }
    }
}

Response

{
    "Account": {
        "@url": "https://api.fortnox.se/3/accounts/1070?financialyear=1",
        "Active": false,
        "BalanceBroughtForward": 0,
        "BalanceCarriedForward": 0,
        "CostCenter": "",
        "CostCenterSettings": "ALLOWED",
        "Description": "Goodwill",
        "Number": 1070,
        "Project": 0,
        "ProjectSettings": "ALLOWED",
        "SRU": 7201,
        "TransactionInformation": "",
        "TransactionInformationSettings": "ALLOWED",
        "VATCode": null,
        "Year": 1
    }
}

Request

require 'net/http'
require 'json'

def send_request
    # Account (PUT )

    begin
        uri = URI('https://api.fortnox.se/3/accounts/1070')

        # Create client          
        http = Net::HTTP.new(uri.host, uri.port)

        dict = {
            "Account" => {
                "Active" => false,
                "Number" => 1070
            }
        }
        body = JSON.dump(dict)

        # Create Request
        req =  Net::HTTP::Put.new(uri)
        # Add headers
        req.add_field "Access-Token", "61cf63ae-4ab9-4a95-9db5-753781c4f41f"
        # Add headers
        req.add_field "Client-Secret", "3Er4kHXZTJ"
        # Add headers
        req.add_field "Content-Type", "application/json"
        # Add headers
        req.add_field "Accept", "application/json"
        # Set header and body
        req.add_field "Content-Type", "application/json"
        req.body = body

        # Fetch Request
        res = http.request(req)
        puts "Response HTTP Status Code: #{res.code}"
        puts "Response HTTP Response Body: #{res.body}"
    rescue Exception => e
        puts "HTTP Request failed (#{e.message})"
    end
end

Response

{
    "Account": {
        "@url": "https://api.fortnox.se/3/accounts/1070?financialyear=1",
        "Active": false,
        "BalanceBroughtForward": 0,
        "BalanceCarriedForward": 0,
        "CostCenter": "",
        "CostCenterSettings": "ALLOWED",
        "Description": "Goodwill",
        "Number": 1070,
        "Project": 0,
        "ProjectSettings": "ALLOWED",
        "SRU": 7201,
        "TransactionInformation": "",
        "TransactionInformationSettings": "ALLOWED",
        "VATCode": null,
        "Year": 1
    }
}

Request

# Install the Python Requests library:
# `pip install requests`

import requests
import json

def send_request():
    # Account (PUT https://api.fortnox.se/3/accounts/1070)

    try:
        r = requests.put(
            url="https://api.fortnox.se/3/accounts/1070",
            headers = {
                "Access-Token":"61cf63ae-4ab9-4a95-9db5-753781c4f41f",
                "Client-Secret":"3Er4kHXZTJ",
                "Content-Type":"application/json",
                "Accept":"application/json",
            },
            data = json.dumps({
                "Account": {
                    "Active": False,
                    "Number": 1070
                }
            })
        )
        print('Response HTTP Status Code : {status_code}'.format(status_code=r.status_code))
        print('Response HTTP Response Body : {content}'.format(content=r.content))
    except requests.exceptions.RequestException as e:
        print('HTTP Request failed')

Response

{
    "Account": {
        "@url": "https://api.fortnox.se/3/accounts/1070?financialyear=1",
        "Active": false,
        "BalanceBroughtForward": 0,
        "BalanceCarriedForward": 0,
        "CostCenter": "",
        "CostCenterSettings": "ALLOWED",
        "Description": "Goodwill",
        "Number": 1070,
        "Project": 0,
        "ProjectSettings": "ALLOWED",
        "SRU": 7201,
        "TransactionInformation": "",
        "TransactionInformationSettings": "ALLOWED",
        "VATCode": null,
        "Year": 1
    }
}

Using our .NET SDK

Request

AccountConnector connector = new AccountConnector();
Account result = connector.Update(new Account() { Number = "1070", Active = "false" });

Properties

Url string, read-only
Direct URL to the record
Active boolean
If the account is actve
BalanceBroughtForward float
Opening balance of the account
BalanceCarriedForward float, read-only
Closing balance of the account
CostCenter string
Code of the proposed cost center. The code must be of an existing cost center.
CostCenterSettings string
Cost center settings for the account. Can be ALLOWED MANDATORY or NOTALLOWED
Description string, 200 characters, required
Account description
Number integer, 4 digits, sortable, required
Account number
Project string
Number of the proposed project. The number must be of an existing project.
ProjectSettings string
Project settings for the account. Can be ALLOWED MANDATORY or NOTALLOWED
SRU integer, 4 or 5 digits, searchable
SRU code
TransactionInformation string, 100 characters
Proposed transaction information
TransactionInformationSettings string
Transaction information settings for the account. Can be ALLOWED MANDATORY or NOTALLOWED
VATCode string
VAT code
Year integer, read-only
Id of the financial year.