{ "openapi": "3.0.3", "info": { "title": "webhook_listeners", "version": "0.0.1", "description": "Send notifications to external services whenever something important happens, like when files are changed or updated.", "license": { "name": "agpl" } }, "components": { "securitySchemes": { "basic_auth": { "type": "http", "scheme": "basic" }, "bearer_auth": { "type": "http", "scheme": "bearer" } }, "schemas": { "OCSMeta": { "type": "object", "required": [ "status", "statuscode" ], "properties": { "status": { "type": "string" }, "statuscode": { "type": "integer" }, "message": { "type": "string" }, "totalitems": { "type": "string" }, "itemsperpage": { "type": "string" } } }, "WebhookInfo": { "type": "object", "required": [ "id", "userId", "httpMethod", "uri", "authMethod" ], "properties": { "id": { "type": "string" }, "userId": { "type": "string" }, "httpMethod": { "type": "string" }, "uri": { "type": "string" }, "event": { "type": "string" }, "eventFilter": { "type": "object", "additionalProperties": { "type": "object" } }, "userIdFilter": { "type": "string" }, "headers": { "type": "object", "additionalProperties": { "type": "string" } }, "authMethod": { "type": "string" }, "authData": { "type": "object", "additionalProperties": { "type": "object" } }, "tokenNeeded": { "type": "object", "nullable": true, "properties": { "user_ids": { "type": "object", "additionalProperties": { "type": "string" } }, "user_roles": { "type": "object", "additionalProperties": { "type": "string" } } } } } } } }, "paths": { "/ocs/v2.php/apps/webhook_listeners/api/v1/webhooks": { "get": { "operationId": "webhooks-index", "summary": "List registered webhooks", "description": "This endpoint requires admin access", "tags": [ "webhooks" ], "security": [ { "bearer_auth": [] }, { "basic_auth": [] } ], "parameters": [ { "name": "uri", "in": "query", "description": "The callback URI to filter by", "schema": { "type": "string", "nullable": true, "default": null } }, { "name": "OCS-APIRequest", "in": "header", "description": "Required to be true for the API request to pass", "required": true, "schema": { "type": "boolean", "default": true } } ], "responses": { "200": { "description": "Webhook registrations returned", "content": { "application/json": { "schema": { "type": "object", "required": [ "ocs" ], "properties": { "ocs": { "type": "object", "required": [ "meta", "data" ], "properties": { "meta": { "$ref": "#/components/schemas/OCSMeta" }, "data": { "type": "array", "items": { "$ref": "#/components/schemas/WebhookInfo" } } } } } } } } }, "401": { "description": "Current user is not logged in", "content": { "application/json": { "schema": { "type": "object", "required": [ "ocs" ], "properties": { "ocs": { "type": "object", "required": [ "meta", "data" ], "properties": { "meta": { "$ref": "#/components/schemas/OCSMeta" }, "data": {} } } } } } } }, "403": { "description": "Logged in account must be an admin", "content": { "application/json": { "schema": { "type": "object", "required": [ "ocs" ], "properties": { "ocs": { "type": "object", "required": [ "meta", "data" ], "properties": { "meta": { "$ref": "#/components/schemas/OCSMeta" }, "data": {} } } } } } } } } }, "post": { "operationId": "webhooks-create", "summary": "Register a new webhook", "description": "This endpoint requires admin access", "tags": [ "webhooks" ], "security": [ { "bearer_auth": [] }, { "basic_auth": [] } ], "requestBody": { "required": true, "content": { "application/json": { "schema": { "type": "object", "required": [ "httpMethod", "uri", "event" ], "properties": { "httpMethod": { "type": "string", "description": "HTTP method to use to contact the webhook" }, "uri": { "type": "string", "description": "Webhook URI endpoint" }, "event": { "type": "string", "description": "Event class name to listen to" }, "eventFilter": { "type": "object", "nullable": true, "description": "Mongo filter to apply to the serialized data to decide if firing", "additionalProperties": { "type": "object" } }, "userIdFilter": { "type": "string", "nullable": true, "description": "User id to filter on. The webhook will only be called by requests from this user. Empty or null means no filtering." }, "headers": { "type": "object", "nullable": true, "description": "Array of headers to send", "additionalProperties": { "type": "string" } }, "authMethod": { "type": "string", "nullable": true, "enum": [ "none", "header" ], "description": "Authentication method to use" }, "authData": { "type": "object", "nullable": true, "description": "Array of data for authentication", "additionalProperties": { "type": "object" } }, "tokenNeeded": { "type": "object", "nullable": true, "default": null, "description": "List of user ids for which to include auth tokens in the event. Has two fields: \"user_ids\" list of user uids for which tokens are needed, \"user_roles\" list of roles (users not defined by their ID but by the role they have in the webhook event) for which tokens can be included. Possible roles: \"owner\" for the user creating the webhook, \"trigger\" for the user triggering the webhook call. Requested auth tokens are valid for 1 hour after receiving them in the event call request.", "properties": { "user_ids": { "type": "array", "items": { "type": "string" } }, "user_roles": { "type": "array", "items": { "type": "string" } } } } } } } } }, "parameters": [ { "name": "ex-app-id", "in": "header", "schema": { "type": "string" } }, { "name": "OCS-APIRequest", "in": "header", "description": "Required to be true for the API request to pass", "required": true, "schema": { "type": "boolean", "default": true } } ], "responses": { "200": { "description": "Webhook registration returned", "content": { "application/json": { "schema": { "type": "object", "required": [ "ocs" ], "properties": { "ocs": { "type": "object", "required": [ "meta", "data" ], "properties": { "meta": { "$ref": "#/components/schemas/OCSMeta" }, "data": { "$ref": "#/components/schemas/WebhookInfo" } } } } } } } }, "400": { "description": "Bad request", "content": { "application/json": { "schema": { "type": "object", "required": [ "ocs" ], "properties": { "ocs": { "type": "object", "required": [ "meta", "data" ], "properties": { "meta": { "$ref": "#/components/schemas/OCSMeta" }, "data": {} } } } } } } }, "403": { "description": "Insufficient permissions", "content": { "application/json": { "schema": { "anyOf": [ { "type": "object", "required": [ "ocs" ], "properties": { "ocs": { "type": "object", "required": [ "meta", "data" ], "properties": { "meta": { "$ref": "#/components/schemas/OCSMeta" }, "data": {} } } } }, { "type": "object", "required": [ "ocs" ], "properties": { "ocs": { "type": "object", "required": [ "meta", "data" ], "properties": { "meta": { "$ref": "#/components/schemas/OCSMeta" }, "data": {} } } } } ] } } } }, "401": { "description": "Current user is not logged in", "content": { "application/json": { "schema": { "type": "object", "required": [ "ocs" ], "properties": { "ocs": { "type": "object", "required": [ "meta", "data" ], "properties": { "meta": { "$ref": "#/components/schemas/OCSMeta" }, "data": {} } } } } } } } } } }, "/ocs/v2.php/apps/webhook_listeners/api/v1/webhooks/{id}": { "get": { "operationId": "webhooks-show", "summary": "Get details on a registered webhook", "description": "This endpoint requires admin access", "tags": [ "webhooks" ], "security": [ { "bearer_auth": [] }, { "basic_auth": [] } ], "parameters": [ { "name": "id", "in": "path", "description": "id of the webhook", "required": true, "schema": { "type": "integer", "format": "int64" } }, { "name": "OCS-APIRequest", "in": "header", "description": "Required to be true for the API request to pass", "required": true, "schema": { "type": "boolean", "default": true } } ], "responses": { "200": { "description": "Webhook registration returned", "content": { "application/json": { "schema": { "type": "object", "required": [ "ocs" ], "properties": { "ocs": { "type": "object", "required": [ "meta", "data" ], "properties": { "meta": { "$ref": "#/components/schemas/OCSMeta" }, "data": { "$ref": "#/components/schemas/WebhookInfo" } } } } } } } }, "404": { "description": "Webhook not found", "content": { "application/json": { "schema": { "type": "object", "required": [ "ocs" ], "properties": { "ocs": { "type": "object", "required": [ "meta", "data" ], "properties": { "meta": { "$ref": "#/components/schemas/OCSMeta" }, "data": {} } } } } } } }, "401": { "description": "Current user is not logged in", "content": { "application/json": { "schema": { "type": "object", "required": [ "ocs" ], "properties": { "ocs": { "type": "object", "required": [ "meta", "data" ], "properties": { "meta": { "$ref": "#/components/schemas/OCSMeta" }, "data": {} } } } } } } }, "403": { "description": "Logged in account must be an admin", "content": { "application/json": { "schema": { "type": "object", "required": [ "ocs" ], "properties": { "ocs": { "type": "object", "required": [ "meta", "data" ], "properties": { "meta": { "$ref": "#/components/schemas/OCSMeta" }, "data": {} } } } } } } } } }, "post": { "operationId": "webhooks-update", "summary": "Update an existing webhook registration", "description": "This endpoint requires admin access", "tags": [ "webhooks" ], "security": [ { "bearer_auth": [] }, { "basic_auth": [] } ], "requestBody": { "required": true, "content": { "application/json": { "schema": { "type": "object", "required": [ "httpMethod", "uri", "event" ], "properties": { "httpMethod": { "type": "string", "description": "HTTP method to use to contact the webhook" }, "uri": { "type": "string", "description": "Webhook URI endpoint" }, "event": { "type": "string", "description": "Event class name to listen to" }, "eventFilter": { "type": "object", "nullable": true, "description": "Mongo filter to apply to the serialized data to decide if firing", "additionalProperties": { "type": "object" } }, "userIdFilter": { "type": "string", "nullable": true, "description": "User id to filter on. The webhook will only be called by requests from this user. Empty or null means no filtering." }, "headers": { "type": "object", "nullable": true, "description": "Array of headers to send", "additionalProperties": { "type": "string" } }, "authMethod": { "type": "string", "nullable": true, "enum": [ "none", "header" ], "description": "Authentication method to use" }, "authData": { "type": "object", "nullable": true, "description": "Array of data for authentication", "additionalProperties": { "type": "object" } }, "tokenNeeded": { "type": "object", "nullable": true, "default": null, "description": "List of user ids for which to include auth tokens in the event. Has two fields: \"user_ids\" list of user uids for which tokens are needed, \"user_roles\" list of roles (users not defined by their ID but by the role they have in the webhook event) for which tokens can be included. Possible roles: \"owner\" for the user creating the webhook, \"trigger\" for the user triggering the webhook call. Requested auth tokens are valid for 1 hour after receiving them in the event call request.", "properties": { "user_ids": { "type": "array", "items": { "type": "string" } }, "user_roles": { "type": "array", "items": { "type": "string" } } } } } } } } }, "parameters": [ { "name": "id", "in": "path", "description": "id of the webhook", "required": true, "schema": { "type": "integer", "format": "int64" } }, { "name": "ex-app-id", "in": "header", "schema": { "type": "string" } }, { "name": "OCS-APIRequest", "in": "header", "description": "Required to be true for the API request to pass", "required": true, "schema": { "type": "boolean", "default": true } } ], "responses": { "200": { "description": "Webhook registration returned", "content": { "application/json": { "schema": { "type": "object", "required": [ "ocs" ], "properties": { "ocs": { "type": "object", "required": [ "meta", "data" ], "properties": { "meta": { "$ref": "#/components/schemas/OCSMeta" }, "data": { "$ref": "#/components/schemas/WebhookInfo" } } } } } } } }, "400": { "description": "Bad request", "content": { "application/json": { "schema": { "type": "object", "required": [ "ocs" ], "properties": { "ocs": { "type": "object", "required": [ "meta", "data" ], "properties": { "meta": { "$ref": "#/components/schemas/OCSMeta" }, "data": {} } } } } } } }, "403": { "description": "Insufficient permissions", "content": { "application/json": { "schema": { "anyOf": [ { "type": "object", "required": [ "ocs" ], "properties": { "ocs": { "type": "object", "required": [ "meta", "data" ], "properties": { "meta": { "$ref": "#/components/schemas/OCSMeta" }, "data": {} } } } }, { "type": "object", "required": [ "ocs" ], "properties": { "ocs": { "type": "object", "required": [ "meta", "data" ], "properties": { "meta": { "$ref": "#/components/schemas/OCSMeta" }, "data": {} } } } } ] } } } }, "401": { "description": "Current user is not logged in", "content": { "application/json": { "schema": { "type": "object", "required": [ "ocs" ], "properties": { "ocs": { "type": "object", "required": [ "meta", "data" ], "properties": { "meta": { "$ref": "#/components/schemas/OCSMeta" }, "data": {} } } } } } } } } }, "delete": { "operationId": "webhooks-destroy", "summary": "Remove an existing webhook registration", "description": "This endpoint requires admin access", "tags": [ "webhooks" ], "security": [ { "bearer_auth": [] }, { "basic_auth": [] } ], "parameters": [ { "name": "id", "in": "path", "description": "id of the webhook", "required": true, "schema": { "type": "integer", "format": "int64" } }, { "name": "OCS-APIRequest", "in": "header", "description": "Required to be true for the API request to pass", "required": true, "schema": { "type": "boolean", "default": true } } ], "responses": { "200": { "description": "Boolean returned whether something was deleted", "content": { "application/json": { "schema": { "type": "object", "required": [ "ocs" ], "properties": { "ocs": { "type": "object", "required": [ "meta", "data" ], "properties": { "meta": { "$ref": "#/components/schemas/OCSMeta" }, "data": { "type": "boolean" } } } } } } } }, "400": { "description": "Bad request", "content": { "application/json": { "schema": { "type": "object", "required": [ "ocs" ], "properties": { "ocs": { "type": "object", "required": [ "meta", "data" ], "properties": { "meta": { "$ref": "#/components/schemas/OCSMeta" }, "data": {} } } } } } } }, "403": { "description": "Insufficient permissions", "content": { "application/json": { "schema": { "anyOf": [ { "type": "object", "required": [ "ocs" ], "properties": { "ocs": { "type": "object", "required": [ "meta", "data" ], "properties": { "meta": { "$ref": "#/components/schemas/OCSMeta" }, "data": {} } } } }, { "type": "object", "required": [ "ocs" ], "properties": { "ocs": { "type": "object", "required": [ "meta", "data" ], "properties": { "meta": { "$ref": "#/components/schemas/OCSMeta" }, "data": {} } } } } ] } } } }, "401": { "description": "Current user is not logged in", "content": { "application/json": { "schema": { "type": "object", "required": [ "ocs" ], "properties": { "ocs": { "type": "object", "required": [ "meta", "data" ], "properties": { "meta": { "$ref": "#/components/schemas/OCSMeta" }, "data": {} } } } } } } } } } }, "/ocs/v2.php/apps/webhook_listeners/api/v1/webhooks/byappid/{appid}": { "delete": { "operationId": "webhooks-delete-by-app-id", "summary": "Remove all existing webhook registration mapped to an AppAPI app id", "description": "This endpoint requires admin access", "tags": [ "webhooks" ], "security": [ { "bearer_auth": [] }, { "basic_auth": [] } ], "parameters": [ { "name": "appid", "in": "path", "description": "id of the app, as in the ex-app-id for creation", "required": true, "schema": { "type": "string" } }, { "name": "OCS-APIRequest", "in": "header", "description": "Required to be true for the API request to pass", "required": true, "schema": { "type": "boolean", "default": true } } ], "responses": { "200": { "description": "Integer number of registrations deleted", "content": { "application/json": { "schema": { "type": "object", "required": [ "ocs" ], "properties": { "ocs": { "type": "object", "required": [ "meta", "data" ], "properties": { "meta": { "$ref": "#/components/schemas/OCSMeta" }, "data": { "type": "integer", "format": "int64" } } } } } } } }, "400": { "description": "Bad request", "content": { "application/json": { "schema": { "type": "object", "required": [ "ocs" ], "properties": { "ocs": { "type": "object", "required": [ "meta", "data" ], "properties": { "meta": { "$ref": "#/components/schemas/OCSMeta" }, "data": {} } } } } } } }, "403": { "description": "Insufficient permissions", "content": { "application/json": { "schema": { "anyOf": [ { "type": "object", "required": [ "ocs" ], "properties": { "ocs": { "type": "object", "required": [ "meta", "data" ], "properties": { "meta": { "$ref": "#/components/schemas/OCSMeta" }, "data": {} } } } }, { "type": "object", "required": [ "ocs" ], "properties": { "ocs": { "type": "object", "required": [ "meta", "data" ], "properties": { "meta": { "$ref": "#/components/schemas/OCSMeta" }, "data": {} } } } } ] } } } }, "401": { "description": "Current user is not logged in", "content": { "application/json": { "schema": { "type": "object", "required": [ "ocs" ], "properties": { "ocs": { "type": "object", "required": [ "meta", "data" ], "properties": { "meta": { "$ref": "#/components/schemas/OCSMeta" }, "data": {} } } } } } } } } } } }, "tags": [] }