Introduction

Configuration

WhatsAPI uses a YAML file to store all the configuration required to run the API. You can find the sample config file here.


Config file

Here is the sample config file.

database:
  host: postgres
  port: 5434
  user: root
  password: root
  database: whatsapi

defaults:
  webhook_url: http://localhost:8080/webhook
  send_webhook: true
  client_name: "My Client"
  browser: "chrome"
  http_port: 8083
  socket_port: 8084
  metrics_url: my_metrics
  max_log_size: 10 # in MB

environment: production

credentials:
  key: "my-api-key"
  secret: "my-api-secret"

tls_config:
  https_enabled: true
  hosts:
    - "localhost"

tokens: ["token1", "token2"]

Understanding the config file

The config file is divided into 6 sections.

Database

This section contains the database configuration. You can leave this section as it is if you are using the WhatsAPI Docker image. The Docker image uses PostgreSQL as the database. You can change the database configuration if you are using a different database.

Defaults

This section contains the default values for the API. You can change these values as per your requirements. The following are the default values.

defaults:
  webhook_url: http://localhost:8080/webhook
  send_webhook: true

  client_name: "My Client"
  browser: "chrome"

  http_port: 8083
  socket_port: 8084

  metrics_url: my_metrics

  max_log_size: 10 # in MB

Here is the description of each field.

FieldDescription
webhook_urlThe URL to which the webhook will be sent.
send_webhookWhether to send webhook or not.
client_nameThe name of the visible to user in WhatsApp.
browserThe browser name visible in WhatsApp.
http_portThe port on which the HTTP server will run.
socket_portThe port on which the socket server will run.
metrics_urlThe URL on which the metrics will be exposed.
max_log_sizeThe maximum size of the log file.

Environment

This section contains the environment name. You can set this to production or development. This will be used to set the log level.

Credentials

This section contains the API credentials. You can get your API credentials from the WhatsAPI Dashboard.

TLS Config

This section contains the TLS configuration. You can enable HTTPS by setting https_enabled to true. You can also add the hostnames to the hosts array.

Tokens

This section contains the API tokens. You can add multiple tokens to this array. You can use these tokens to authenticate the API requests.

Previous
Installation