Type Alias TheBasicConstructorArguments

TheBasicConstructorArguments: {
    appSecret?: string | never;
    parsed?: boolean;
    ponyfill?: {
        fetch?: typeof __type;
        subtle?: Pick<typeof crypto.subtle, "importKey" | "sign">;
    };
    secure?: boolean;
    token: string;
    v?: string;
    webhookVerifyToken?: string;
}

The main constructor arguments for the API

Type declaration

  • OptionalappSecret?: string | never

    The app secret, given at setup.

    The secret is used as a signature to validate payload's authenticity.

    To get your app secret, head to Meta for Developers Dashboard, select your app and open Settings -> Basic -> App Secret -> Show.

    If you want to skip the verification and remove the need to provide the secret, set secure to false.

  • Optionalparsed?: boolean

    Whether to return a pre-processed response from the API or the raw fetch response. Intended for low level debugging.

  • Optionalponyfill?: {
        fetch?: typeof __type;
        subtle?: Pick<typeof crypto.subtle, "importKey" | "sign">;
    }

    The ponyfills to use.

    This are meant to provide standard APIs implementations on enviroments that don't have them.

    For example, if using Node 16, you will need to ponyfill the fetch method with any spec complient fetch method.

    With the additions of setup for the most common enviroments, this parameter should no longer be configured manually.

    import { fetch } from "undici";
    import { subtle } from "node:crypto";

    const api = new WhatsAppAPI({
    token: "my-token",
    appSecret: "my-app-secret",
    ponyfill: {
    fetch,
    subtle
    }
    });
    • Optionalfetch?: typeof __type

      The fetch ponyfill to use for the requests. If not specified, it defaults to the fetch function from the enviroment.

    • Optionalsubtle?: Pick<typeof crypto.subtle, "importKey" | "sign">

      The subtle ponyfill to use for the signatures. If not specified, it defaults to crypto.subtle from the enviroment.

  • Optionalsecure?: boolean

    If set to false, none of the API checks will be performed, and it will be used in a less secure way.

    Defaults to true.

  • token: string

    The API token, given at setup. You must provide an API token to use the framework.

    It can either be a temporal or permanent one.

    In order to create a permanent token, first make sure you have linked your WhatsApp account to a Meta Commercial Account in Meta for Developers Dashboard.

    After that, head to Bussiness Settings, select your app, create a new system user with admin role. Then click "Add Actives", select Apps -> Your App -> App Administrator.

    And this was the point were Meta decided I was too sus because I created a second bussiness to follow my own tutorial, and as I didn't want to give them my ID, they banned my account.

    If you read until here, you probably will figure it out. It's not that hard after getting in the right place.

    Really wish WhatsApp gets away from Meta soon...

    (Sorry for the rant, here's the actual documentation :)

  • Optionalv?: string

    The version of the API, defaults to DEFAULT_API_VERSION.

  • OptionalwebhookVerifyToken?: string

    The webhook verify token, configured at setup. Used exclusively to verify the server against WhatsApp's servers via the GET method.

    Not required by default, but calling this.get() without it will result in an error.