# Welcome!

## Welcome to Invitelogger api

Please note this api is on a beta stage.&#x20;

{% content-ref url="/pages/WpPKmBZKV3d6Q4jPBd2K" %}
[Endpoints](/reference/endpoints)
{% endcontent-ref %}


# Miscellaneous

By using our api, you agree to discord [Terms of services](https://discord.com/tos)

The base url of the api is [<mark style="color:green;">`https://api.invitelogger.me/v1`</mark>](https://api.invitelogger.me/v1)

Please note that all parameters must be sent as a json body (Content type: JSON)


# Authentication

### Beta authentication system

To authenticate yourself against the api you must provide a bearer authorization token through the `Authorization` header. \
You will also need to provide your discord application id & your server id in the json body\
For now each token is linked to a bot id and a to a server id.

As the api is on a beta stage, **only** [**private bot instance**](https://docs.invitelogger.me/pbi/what-is-a-private-bot-instance) owners can request access to it.

### Final authentication system:

Each application will have a bearer token.\
Each discord servers will have a secret.&#x20;


# Endpoints

## Invites

Everything related to invites management

{% content-ref url="/pages/Lsk9jGh1EZsrOK8FW2Lq" %}
[Invites](/reference/endpoints/invites)
{% endcontent-ref %}

### Miscellaneous

Some off-topic endpoints

{% content-ref url="/pages/1TEKlfsYKqQo7d3ycFsb" %}
[Miscellaneous](/reference/endpoints/misc)
{% endcontent-ref %}


# Invites

## User actions

## Retrieve invite count from an user

<mark style="color:blue;">`GET`</mark> `https://api.invitelogger.me/v1/invites/user`

Basically what the /invites command do

#### Request Body

| Name                                          | Type                 | Description                            |
| --------------------------------------------- | -------------------- | -------------------------------------- |
| bot\_id<mark style="color:red;">\*</mark>     | discord id as string | Retrieve invites data from what bot    |
| guild\_id<mark style="color:red;">\*</mark>   | discord id as string | Retrieve invites data from what server |
| inviter\_id<mark style="color:red;">\*</mark> | discord id as string | Retrieve invites data from whom        |

{% tabs %}
{% tab title="200: OK user invites amount" %}

```javascript
{
    "total":0, 
    "leaves":0,
    "fake":0,
    "bonus":0,
    "real":0
}
```

{% endtab %}
{% endtabs %}

## Invite code

## Retrieve joins from a specific invite code

<mark style="color:blue;">`GET`</mark> `https://api.invitelogger.me/v1/invites/code`

Get an array of invited members through a specific invite code

#### Request Body

| Name                                           | Type                                            | Description                            |
| ---------------------------------------------- | ----------------------------------------------- | -------------------------------------- |
| bot\_id<mark style="color:red;">\*</mark>      | discord id as string                            | Retrieve invites data from what bot    |
| guild\_id<mark style="color:red;">\*</mark>    | discord id as string                            | Retrieve invites data from what server |
| invite\_code<mark style="color:red;">\*</mark> | invite code as string (without the discord.gg/) | Retrive invited members from this code |

{% tabs %}
{% tab title="200: OK invited members list example:" %}

```javascript
    {
        "created_at": "2020-08-04T08:14:37.000Z", // join date
        "updated_at": "2020-11-08T08:36:25.000Z", // if cleared = clear date, if left probably leave date.
        "member_id": "417977361011572747", // id of the invited member 
        "fake": false,  // if the invite has been counted as fake
        "left": true, // if the member has left the server 
        "cleared": false // if the invite has been cleared using the /resetinvites command
    },
```

{% endtab %}
{% endtabs %}


# Miscellaneous

## Authentication check

## Check your credentials

<mark style="color:blue;">`GET`</mark> `https://api.invitelogger.me/v1/checkauth`

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

```javascript
{
    "message": "Welcome aboard! You are sucessfully authenticated."
}
```

{% endtab %}
{% endtabs %}


# Resources


# Fake codes

To know the reason of why each invite has been considered as fake, the fakeCode field gives a bitwise code (same way as discord permission system)

<table><thead><tr><th>Name</th><th width="117">Value</th><th width="287">Description</th><th width="186" data-type="checkbox">Default true</th><th>Gold</th></tr></thead><tbody><tr><td>YOUNG</td><td>1 (1 &#x3C;&#x3C; 0)</td><td>User account has been created too recently</td><td>false</td><td></td></tr><tr><td>SELF</td><td>2 (1 &#x3C;&#x3C; 1)</td><td>User has joined using their own invite code</td><td>false</td><td></td></tr><tr><td>NOPFP</td><td>4 (1 &#x3C;&#x3C; 2)</td><td>User doesn't have a customized profile picture</td><td>false</td><td></td></tr><tr><td>ALREADYJOINED</td><td>8 (1 &#x3C;&#x3C; 3)</td><td>Has joined the server in the past</td><td>false</td><td></td></tr><tr><td>REQUIREROLE</td><td>16 (1 &#x3C;&#x3C; 4)</td><td>Account needs to recieve a specific role to be marked as valid</td><td>true</td><td>🏅</td></tr><tr><td>REQUIREDCVERIF</td><td>32 (1 &#x3C;&#x3C; 5)</td><td>Account needs to be verified through double counter discord bot</td><td>true</td><td>🏅</td></tr></tbody></table>

{% embed url="<https://medium.com/@venuebook_j/using-bitfields-in-javascript-for-simple-permission-systems-fce3b35aee58>" %}


# Introduction

We are happy to release the first versions of the webhook system on InviteLogger. \
Its goal is to allow more flexibility around our services and allow our customer to implement their own automations to expand even more InviteLogger's capabilities.

Use case example: *I want to register every inviter in a google spreadsheet*

{% hint style="info" %}
Please note that this feature is only available for gold (=premium) users
{% endhint %}

## What is a webhook?

<figure><img src="/files/nGjER7zhyFNFSMcGboVw" alt=""><figcaption><p>Image from markheath.net</p></figcaption></figure>

Webhooks are a way for public service such as InviteLogger to spontaneously interact with external services like zapier or even your own private api.\
Once a certain event is triggered on the bot (i.e a member joining your server), InviteLogger will send a request with a specified payload to your services.&#x20;

## How to set up InviteLogger webhooks ?

To use InviteLogger webhooks you must setup a way to receive them by :

* Registering to an automation platform (zapier, ifttt.com, make.com...)
* Or by installing your own web service to listen for InviteLogger webhooks and handle data on your side (coding skills required) <br>

  <figure><img src="/files/uQyXTYstCZ9baZG5cDGT" alt=""><figcaption><p>What it looks like on zapier</p></figcaption></figure>

  Once your service is ready, paste run the `/webhookconfig` command and provide your link and an authentication key to ensure webhook security.


# Content

Every webhook is formatted like this

```typescript
{
    botID: string; // 499595256270946326 if main bot, will change if Private bot
    type: string; // name of the webhook event (ie member.join)
    data: any; // see below
    timestamp: number // webhook sent timestamp
}
```

For data see this page:

{% content-ref url="/pages/w8DzXTgOhjHVeCK5XaO2" %}
[Members](/webhooks/content/members)
{% endcontent-ref %}


# Members

## members.join

This webhook is fired every time someone joins your server

{% tabs %}
{% tab title="Content" %}
{% code fullWidth="true" %}

```typescript
{
   guild: {
      id: string;
      name: string;
      icon?: string;
    };
    member: {
      id: string;
      username: string;
      discriminator: string;
      avatar: string;
      bot: boolean;
      joinedAt: number;
      createdAt: number;
    };
    inviter: {
      type: "user" | "vanity" | "unknown" | "oauth2";
      user?: { // only if type = user
        id: string;
        username: string;
        discriminator: string;
        avatar?: string;
        bot?: boolean;
      };
      invites?: { // only if type = user
        total: number,
        leaves: number,
        fake: number,
        bonus: number,
        joins: number,
        rank?: number // might not be shown, do no rely on it
      },
      code?: string  // only if vanity or user
    },
    fakeData: {
      isFake: boolean, // if the join has been counted as fake
      code: number // bitfield telling why the join has been counted as fake
    }
}
```

{% endcode %}
{% endtab %}

{% tab title="Example" %}

```json
{
  "botID": "637662603564417024",
  "type": "member.join",
  "data": {
    "guild": {
      "id": "759100646120751124",
      "name": "test invitelogger",
      "icon": null
    },
    "member": {
      "id": "525813997241630732",
      "username": "chaun1403",
      "discriminator": "0",
      "avatar": "https://cdn.discordapp.com/avatars/525813997241630732/680097c6af2890418164a9d7bd3bd91b.webp?size=128",
      "bot": false,
      "joinedAt": 1694953136345,
      "createdAt": 1545434226094
    },
    "inviter": {
      "type": "user",
      "user": {
        "id": "417977361011572747",
        "username": "chaun14",
        "discriminator": "0",
        "avatar": null,
        "bot": false
      },
      "invites": {
        "total": 239,
        "leaves": 7,
        "fake": 4,
        "bonus": 240,
        "joins": 10
      },
      "code": "RMJpYgzz"
    },
    "fakeData": {
      "isFake": true,
      "code": 16
    }
  },
  "timestamp": 1694953134956
}
```

{% endtab %}
{% endtabs %}

***

## members.leave

This webhook is fired every time someone leaves your server

{% tabs %}
{% tab title="Content" %}

```typescript
{
   guild: {
      id: string;
      name: string;
      icon?: string;
    };
    member: {
      id: string;
      username: string;
      discriminator: string;
      avatar: string;
      bot: boolean;
      joinedAt: number;
      createdAt: number;
    };
    inviter: {
      type: "user" | "vanity" | "unknown" | "oauth2";
      user?: { // only if type = user
        id: string;
        username: string;
        discriminator: string;
        avatar?: string;
        bot?: boolean;
      };
      invites?: { // only if type = user
        total: number,
        leaves: number,
        fake: number,
        bonus: number,
        joins: number,
        rank?: number // might not be shown, do no rely on it
      },
      code?: string  // only if vanity or user
    },
}
```

{% endtab %}

{% tab title="Example" %}

```json
{
  "botID": "637662603564417024",
  "type": "member.leave",
  "data": {
    "guild": {
      "id": "759100646120751124",
      "name": "test invitelogger",
      "icon": null
    },
    "member": {
      "id": "525813997241630732",
      "username": "izzitox",
      "discriminator": "0",
      "avatar": "https://cdn.discordapp.com/avatars/525813997241630732/680097c6af2890418164a9d7bd3bd91b.webp?size=128",
      "bot": false,
      "joinedAt": 1694953089631,
      "createdAt": 1545434226094
    },
    "inviter": {
      "type": "user",
      "user": {
        "id": "417977361011572747",
        "username": "chaun14",
        "discriminator": "0",
        "avatar": "https://cdn.discordapp.com/avatars/417977361011572747/a_758f6228a02b2b714baeb10dde7f17c4.webp?size=128",
        "bot": false
      },
      "invites": {
        "total": 239,
        "leaves": 7,
        "fake": 3,
        "bonus": 240,
        "joins": 9
      },
      "code": "RMJpYgzz"
    }
  },
  "timestamp": 1694953120091
}
```

{% endtab %}
{% endtabs %}

***

## members.fakeUpdate

This webhook is fired every time someone's join become non fake (i.e when there is a role requirement fake parameter)

{% tabs %}
{% tab title="Content" %}

```typescript
{
   guild: {
      id: string;
      name: string;
      icon?: string;
    };
    member: {
      id: string;
      username: string;
      discriminator: string;
      avatar: string;
      bot: boolean;
      joinedAt: number;
      createdAt: number;
    };
    inviter: {
      type: "user" | "vanity" | "unknown" | "oauth2";
      user?: { // only if type = user
        id: string;
        username: string;
        discriminator: string;
        avatar?: string;
        bot?: boolean;
      };
       invites?: {
        total: number,
        leaves: number,
        fake: number,
        bonus: number,
        joins: number,
        rank?: number // might not be shown, do no rely on it
      },
      code?: string  // only if vanity or user
    }, 
    fakeData: {
      before: {
        isFake: boolean,
        code: number
      },
      after: {
        isFake: boolean,
        code: number
      }
    }
}
```

{% endtab %}

{% tab title="Example" %}

```json
{
  "botID": "637662603564417024",
  "type": "member.fakeUpdate",
  "data": {
    "guild": {
      "id": "759100646120751124",
      "name": "test invitelogger",
      "icon": null
    },
    "member": {
      "id": "525813997241630732",
      "username": "izzitox",
      "discriminator": "0",
      "avatar": "https://cdn.discordapp.com/avatars/525813997241630732/680097c6af2890418164a9d7bd3bd91b.webp?size=128",
      "bot": false,
      "joinedAt": 1694953136345,
      "createdAt": 1545434226094
    },
    "inviter": {
      "type": "user",
      "user": {
        "id": "417977361011572747",
        "username": "chaun14",
        "discriminator": "0",
        "avatar": "https://cdn.discordapp.com/avatars/417977361011572747/a_758f6228a02b2b714baeb10dde7f17c4.gif?size=128",
        "bot": false
      },
      "invites": {
        "total": 239,
        "leaves": 7,
        "fake": 4,
        "bonus": 240,
        "joins": 10
      }
    },
    "fakeData": {
      "before": {
        "isFake": true,
        "code": 16
      },
      "after": {
        "isFake": false,
        "code": 0
      }
    }
  },
  "timestamp": 1694953157824
}
```

{% endtab %}
{% endtabs %}


