API clients can be generated for most major languages with the help of Swagger Code Generator

All of the Ingrid services provide HTTP endpoints with Swagger specifications. These can be found at;

Use Swagger Code Generator for your language to create a client.


We have two environments that you can leverage:


When you register with Ingrid you will get an API token. This token must be send with every request in the Authorization HTTP header with the Bearer prefix followed by base64 encoded token. It will look something like this.

POST /v1/cos/session.create HTTP/1.1
Authorization: Bearer ZjQ1Mjk0MDMyNTNhNDdmNmIyOTI3NDE2ODUzNTU0NmI=
Content-Type: application/json

Swagger client generation

In order to generate a Swagger client you need to install swagger-codegen tool on your computer and in order to generate a client you have to provide it with a Swagger specification.

For example to generate a PHP client for SIW.

$ swagger-codegen generate -l php -i -o siw-client

The process is similar to other programming languages. Flag -l is where you specify the client language and -o is the target output directory. There are plenty of other command line options. Please consult the swagger-codegen documentation for that information.


The API token should be kept private and treated as a password. Hence all calls to our API should be done from the backend.

Client usage

When you register with Ingrid you will get a API token. This token needs to be sent with every request in the Authorization HTTP header with the Bearer prefix followed by base64 encoded representation of the token.

PHP Client Example


Ingrid\Configuration::getDefaultConfiguration()->setApiKey('Authorization', base64_encode('YOUR_API_KEY'));
Ingrid\Configuration::getDefaultConfiguration()->setApiKeyPrefix('Authorization', 'Bearer');

$client = new Ingrid\Api\DefaultApi();

$item = new CartItem();

$cart = new Cart();

$req = new \Ingrid\SIW\Model\CreateSessionRequest();

try {
    $response = $client->createSession($req);
} catch (Exception $e) {
    echo 'Exception calling CreateSession: ', $e->getMessage(), PHP_EOL;


Dotnet Client Example

Here is an example on how to generate a C# client and how to use it in your code.

$ swagger-codegen generate -l csharp -i -DpackageName=Ingrid.SIW -o Ingrid

Using the generated client should be straight forward.

using System;
using System.Diagnostics;
using Ingrid.SIW.Api;
using Ingrid.SIW.Client;
using Ingrid.SIW.Model;

namespace Example
    public class ClientTest
        public void main()
            var apiKey = "YOUR_INGRID_API_KEY";
            var bytes = System.Text.Encoding.UTF8.GetBytes(apiKey);
            var encodedApikey = Convert.ToBase64String(bytes);

            Configuration.Default.ApiKey.Add("Authorization", encodedApikey);
            Configuration.Default.ApiKeyPrefix.Add("Authorization", "Bearer");

            var client = new DefaultApi();

            var req = new CreateSessionRequest{
              PurchaseCountry = "SE",
              PurchaseCurrency = "SEK",
              Locale = "sv-SE",
              Cart = new Cart{
                TotalValue = 15000,
                Currency = "SEK",
                Items = new Items[] {
                  new CartItem {
                     Sku = "SKU001"
                     Name = "Sneakers"

                var response = client.CreateSession(req);
            catch (Exception e)
                Debug.Print("Exception calling SIW API: " + e.Message );