Vlad Zinko
Vlad Zinko

Reputation: 21

Can't create webhook through v2 api endpoint

I am trying to dispatch webhook create endpoint and getting 403 Forbidden response code with no error information in body. My request looks like:

POST /v2/apps/618ce23498488b00e1582723/integrations/618ce235a6ccf400e1a4b992/webhooks HTTP/1.1
Host: api.smooch.io
Content-Type: application/json
Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiIsImtpZCI6ImFwcF82MThjZTIzNGZiYTk5MDAwZTFiZDgyYWMifQ.eyJzY29wZSI6ImFwcCJ9.hXigeREGoUQ8YtM_gPUXfgWEGumbnlbBNLk_*******
Content-Length: 120

{
    "target": "https://example.com/inbound-smooch-request",
    "triggers": [
        "conversation:message"
    ]
}

Response I am getting:

{"errors":[{"code":"forbidden","title":"Forbidden"}]}

That's how I generate Bearer token:

$signer = new Sha256();

    $a = (new Builder())
        ->withHeader('alg', 'HS256')
        ->withHeader('typ', 'JWT')
        ->withHeader('kid', 'app_618ce234fba99000e1bd8***')
        ->withClaim('scope', 'app')
        ->getToken($signer, new Key('4K5KoVqLixLOUrkJSebr4rFsvZAu66d2WD8WEhXDgAZnJaltEpnHWpF_PUwQUGuNlFnBXvr8mtGsvNKj******'));
    echo $a . PHP_EOL;
    die();

Webhook api documentation: https://docs.smooch.io/rest/#operation/createWebhook

There is a bearerAuth (integration, app) explanation but there is no information what does this means. Documentation says that there are only two scopes: account and app. So what is this? Other endpoints work normally (app create, app keys create, integration create)

Tried Basic auth also but it did not help.

Upvotes: 2

Views: 288

Answers (1)

Adam Smooch
Adam Smooch

Reputation: 1322

The integrations/:id/webhooks endpoints are used (in v2) to create/update/remove webhooks from an existing customIntegration (integration with type: custom).

This endpoint will allow you to create a new integration, and when you set type: custom, it will also accept a list of webhooks: https://docs.smooch.io/rest/#operation/createIntegration create integration > type: custom

Upvotes: 1

Related Questions