# How to create an e-conomic app for Apideck

e-conomic doesn't use OAuth. Each connection uses two tokens:

- **App Secret Token**: identifies your app. You enter it once in Apideck.
- **Agreement Grant Token**: identifies one customer's e-conomic company. Each customer gets this token when they approve your app and pastes it into Vault.

This guide covers your side: creating the app, entering its App Secret Token in Apideck, and giving customers the link they need to approve access.

Before you start, you'll need a free e-conomic developer agreement. For e-conomic's own walkthrough, see [Connecting to the e-conomic API](https://www.e-conomic.com/developer/connect).

## 1. Sign up for a developer agreement

Go to the [e-conomic Developer Network](https://www.e-conomic.com/developer) and sign up for a free developer agreement.

A developer agreement is only for managing apps. To test, see [Testing your setup](#testing-your-setup).

## 2. Create a new app with the Superuser role

1. Log in to your developer agreement.
2. Open the **Apps** tab and click **New app**.
3. Give the app a name your customers will recognize.
4. Choose the **Superuser** role.

The role limits which data the app can access, and you can't change it after you create the app. If you pick a narrower role, some data will be out of reach. For example, an app with the Bookkeeping role can't read customers or products. If you picked the wrong role, create a new app with the Superuser role.

## 3. Copy the App Secret Token

As soon as you create the app, e-conomic shows its **App Secret Token**. Copy it and store it somewhere safe, because e-conomic shows it only once.

If you lose it, you can reset the token in your developer agreement. Resetting it invalidates the old token, so every existing connection fails with 401 until you enter the new token in Apideck (step 5).

## 4. Leave the redirect URL empty

Each app has an optional redirect URL setting. Leave it **empty**.

When there's no redirect URL, e-conomic shows the Agreement Grant Token on screen after a customer approves your app, so the customer can copy it into Vault. When a redirect URL is set, e-conomic sends the token to that URL instead, and the customer never sees it. Vault can't receive the token that way.

## 5. Enter the App Secret Token in Apideck

1. Open the [Apideck e-conomic connector settings](https://platform.apideck.com/configuration/accounting/e-conomic) in the Apideck Dashboard.
2. Under **e-conomic App Credentials**, paste your token into **App Secret Token** (required).
3. **App Public Token** is optional. Apideck doesn't need it to make API calls.
4. Save.

## 6. Share the Installation URL with your customers

In your developer agreement, click the app's **tokens** button to get its **Installation URL**. Send this link to every customer who wants to connect.

The customer opens the link while logged in to their e-conomic company and approves access. e-conomic then shows an Agreement Grant Token, which the customer pastes into the **Agreement Grant Token** field in Vault. Your customer-facing connection guide covers those steps.

To set the language of the approval pages, add `locale=en-US` (English) or `locale=da-DK` (Danish) as a URL parameter.

## Testing your setup

Test against an e-conomic trial company:

1. Create a free e-conomic trial company.
2. **Log out of your developer agreement.** If you're still logged in, the Installation URL opens the developer agreement instead of the trial company.
3. Log in to the trial company. If you're an administrator, click **Administer** on the trial company first. Then open your app's Installation URL, approve access and copy the Agreement Grant Token.
4. Create a connection in Vault with that token and make a test request.

## FAQ and troubleshooting

**Requests fail with 403 for some resources, such as customers or products.**
The app's role doesn't include that data. The role can't be changed, so create a new app with the Superuser role, enter its App Secret Token in Apideck, and have customers approve the new app through its Installation URL.

**Every connection started failing with 401 at the same time.**
The App Secret Token was most likely reset in the developer agreement, which invalidates the old token. Enter the current token in the [Apideck e-conomic connector settings](https://platform.apideck.com/configuration/accounting/e-conomic). If only one connection fails with 401, that customer needs to approve the app again through the Installation URL.

**The customer doesn't see a token after approving the app.**
Check that the app's redirect URL is empty (step 4).

**The Installation URL opens the developer agreement instead of the company.**
Log out of the developer agreement first, then open the link while logged in to the company.

Still stuck? Contact [Apideck Support](https://help.apideck.com/en/articles/7774658).
