# EmergencyOS Endpoints

{% hint style="info" %}
Beachte, dass das Addon Datenbank Sync aktiviert sein muss
{% endhint %}

Um die Funktionen der API zu nutzen, ist es erforderlich, dass du bei bestimmten Events Anfragen an EmergencyOS sendest.

## Setup&#x20;

Es ist Ihnen vollständig überlassen, von wo und wie Sie Anfragen an die API senden, solange sie der Dokumentation entsprechen.

## Endpoints

Bevor Sie eine Anfrage an die API senden, müssen Sie Ihre Instance ID ermitteln. Dies ist einmalig pro Server/Script-Start erforderlich. Mit dieser Instance ID müssen Sie dann jede weitere Anfrage validieren.

## Get your instance id

<mark style="color:blue;">`GET`</mark> `https://emergencyos.de/api/getInstance`

With this endpoint you can get the InstanceID for your account with which all further requests must be signed

#### Headers

| Name                                                | Type   | Description                     |
| --------------------------------------------------- | ------ | ------------------------------- |
| API-KEY<mark style="color:red;">\*</mark>           | string | Your EmergncyOS API Key         |
| INSTANCE-USERNAME<mark style="color:red;">\*</mark> | string | Your EmergencyOS admin username |
| INSTANCE-PASSWORD<mark style="color:red;">\*</mark> | string | Your EmergencyOS admin password |

{% tabs %}
{% tab title="200: OK Success" %}

```javascript
{
    instanceId: number, // You instance id
}
```

{% endtab %}

{% tab title="203: Non-Authoritative Information Error while reqest" %}

```javascript
{
    string errorMessage //ErrorMessage with more information
}
```

{% endtab %}
{% endtabs %}

Dieser Endpoint sollte aufgerufen werden, sobald ein Spieler eine Rechnung auf dem Server bezahlt hat. Falls die Rechnungs-ID mit einem Ticket verknüpft ist, wird dieses automatisch als "bezahlt" markiert.

## Set a bill as payed in EmergencyOS

<mark style="color:green;">`POST`</mark> `https://emergencyos.de/api/billPayed`

Reports a paid invoice to EmergencyOS and if a ticket exists for this invoice, it will be marked as paid

#### Headers

| Name                                          | Type   | Description             |
| --------------------------------------------- | ------ | ----------------------- |
| API-KEY<mark style="color:red;">\*</mark>     | string | Your EmergncyOS API key |
| INSTANCE-ID<mark style="color:red;">\*</mark> | number | Your instance id        |

#### Request Body

| Name                                     | Type   | Description           |
| ---------------------------------------- | ------ | --------------------- |
| billId<mark style="color:red;">\*</mark> | string | The id of the invoice |

{% tabs %}
{% tab title="200: OK Reqest success" %}

```javascript
```

{% endtab %}

{% tab title="401: Unauthorized Not successfully authorized" %}

```javascript
```

{% endtab %}

{% tab title="400: Bad Request Error with the reqest" %}

```javascript
{
    string errorMessage // Contains more Info about why the reqest failed
}
```

{% endtab %}
{% endtabs %}
