{
  "openapi": "3.1.0",
  "info": {
    "title": "Webhooks REST API",
    "description": "API for managing Webhooks Configuration for Events notification.",
    "version": "v1"
  },
  "servers": [
    {
      "url": "https://apis.objectsgrid.com"
    }
  ],
  "paths": {
    "/webhooks": {
      "post": {
        "summary": "Create object",
        "operationId": "create",
        "security": [
          {
            "accessTokenAuth": [

            ]
          }
        ],
        "parameters": [
          {
            "in": "header",
            "name": "X-ObjectsGrid-AccessPoint",
            "description": "EU or US depending on where your Organization Account is located",
            "schema": {
              "type": "string",
              "enum": [
                "EU",
                "US"
              ]
            },
            "required": true
          },
          {
            "in": "header",
            "name": "X-ObjectsGrid-RestApiVersion",
            "description": "This header allows targeting an API version.\nIf you want to target the latest API version set its value to 'latest'\nIf you want to target the latest stable API version set its value to 'stable'\n",
            "schema": {
              "type": "string"
            },
            "required": false
          },
          {
            "in": "header",
            "name": "X-ObjectsGrid-SessionID",
            "description": "This header allows you to provide a Session ID to be traced through the request stack and returned in the response.\n",
            "schema": {
              "type": "string"
            },
            "required": false
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "https://objectsgrid.com/.well-known/objects-catalog/Webhook/v1/schema.json"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Successfully created the object",
            "headers": {
              "X-ObjectsGrid-CorrelationID": {
                "description": "The Correlation ID is a unique value generated by ObjectsGrid and used for troubleshooting issues",
                "schema": {
                  "type": "string"
                }
              },
              "X-ObjectsGrid-SessionID": {
                "description": "If your request contained this header, it will be included in the response",
                "schema": {
                  "type": "string"
                }
              },
              "ETag": {
                "description": "The object version. Send it in the If-Match header to update, patch or delete this exact version",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "https://objectsgrid.com/.well-known/objects-catalog/Webhook/v1/schema.json"
                }
              }
            }
          },
          "400": {
            "description": "Bad request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "https://objectsgrid.com/.well-known/objects-catalog/ErrorResponse/v1/schema.json"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "https://objectsgrid.com/.well-known/objects-catalog/ErrorResponse/v1/schema.json"
                }
              }
            }
          },
          "409": {
            "description": "Conflict, object already exists",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "https://objectsgrid.com/.well-known/objects-catalog/ErrorResponse/v1/schema.json"
                }
              }
            }
          },
          "429": {
            "description": "Too Many Requests - rate limited",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "https://objectsgrid.com/.well-known/objects-catalog/ErrorResponse/v1/schema.json"
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "https://objectsgrid.com/.well-known/objects-catalog/ErrorResponse/v1/schema.json"
                }
              }
            }
          }
        }
      }
    },
    "/webhooks/{id}": {
      "get": {
        "summary": "Retrieve Object",
        "operationId": "retrieve",
        "security": [
          {
            "accessTokenAuth": [

            ]
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "const": "webhooks-config"
            },
            "description": "ID of the object to retrieve"
          },
          {
            "in": "header",
            "name": "If-None-Match",
            "description": "The ETag of the version you hold: answered 304 Not Modified, with no body and not billed, when the object is still at it. Poll a configuration or flags this way.\n",
            "schema": {
              "type": "string"
            },
            "required": false
          },
          {
            "in": "header",
            "name": "X-ObjectsGrid-AccessPoint",
            "description": "EU or US depending on where your Organization Account is located",
            "schema": {
              "type": "string",
              "enum": [
                "EU",
                "US"
              ]
            },
            "required": true
          },
          {
            "in": "header",
            "name": "X-ObjectsGrid-RestApiVersion",
            "description": "This header allows targeting an API version.\nIf you want to target the latest API version set its value to 'latest'\nIf you want to target the latest stable API version set its value to 'stable'\n",
            "schema": {
              "type": "string"
            },
            "required": false
          },
          {
            "in": "header",
            "name": "X-ObjectsGrid-SessionID",
            "description": "This header allows you to provide a Session ID to be traced through the request stack and returned in the response.\n",
            "schema": {
              "type": "string"
            },
            "required": false
          }
        ],
        "responses": {
          "200": {
            "description": "Successfully retrieved the object",
            "headers": {
              "X-ObjectsGrid-CorrelationID": {
                "description": "The Correlation ID is a unique value generated by ObjectsGrid and used for troubleshooting issues",
                "schema": {
                  "type": "string"
                }
              },
              "X-ObjectsGrid-SessionID": {
                "description": "If your request contained this header, it will be included in the response",
                "schema": {
                  "type": "string"
                }
              },
              "ETag": {
                "description": "The object version. Send it in the If-Match header to update, patch or delete this exact version",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "https://objectsgrid.com/.well-known/objects-catalog/Webhook/v1/schema.json"
                }
              }
            }
          },
          "304": {
            "description": "Not Modified, the object is still at the version If-None-Match named; no body, not billed"
          },
          "400": {
            "description": "Bad request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "https://objectsgrid.com/.well-known/objects-catalog/ErrorResponse/v1/schema.json"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "https://objectsgrid.com/.well-known/objects-catalog/ErrorResponse/v1/schema.json"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "https://objectsgrid.com/.well-known/objects-catalog/ErrorResponse/v1/schema.json"
                }
              }
            }
          },
          "429": {
            "description": "Too Many Requests",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "https://objectsgrid.com/.well-known/objects-catalog/ErrorResponse/v1/schema.json"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "https://objectsgrid.com/.well-known/objects-catalog/ErrorResponse/v1/schema.json"
                }
              }
            }
          }
        }
      },
      "put": {
        "summary": "Update Object",
        "operationId": "update",
        "security": [
          {
            "accessTokenAuth": [

            ]
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "const": "webhooks-config"
            },
            "description": "ID of the object to update"
          },
          {
            "in": "header",
            "name": "X-ObjectsGrid-AccessPoint",
            "description": "EU or US depending on where your Organization Account is located",
            "schema": {
              "type": "string",
              "enum": [
                "EU",
                "US"
              ]
            },
            "required": true
          },
          {
            "in": "header",
            "name": "If-Match",
            "description": "The ETag of the object version being modified, as returned by the Retrieve, Create, Update or Patch operations.\nIf the object has been modified since that version, the request fails with 412 Precondition Failed.\n",
            "schema": {
              "type": "string"
            },
            "required": false
          },
          {
            "in": "header",
            "name": "X-ObjectsGrid-RestApiVersion",
            "description": "This header allows targeting an API version.\nIf you want to target the latest API version set its value to 'latest'\nIf you want to target the latest stable API version set its value to 'stable'\n",
            "schema": {
              "type": "string"
            },
            "required": false
          },
          {
            "in": "header",
            "name": "X-ObjectsGrid-SessionID",
            "description": "This header allows you to provide a Session ID to be traced through the request stack and returned in the response.\n",
            "schema": {
              "type": "string"
            },
            "required": false
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "https://objectsgrid.com/.well-known/objects-catalog/Webhook/v1/schema.json"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successfully updated the object",
            "headers": {
              "X-ObjectsGrid-CorrelationID": {
                "description": "The Correlation ID is a unique value generated by ObjectsGrid and used for troubleshooting issues",
                "schema": {
                  "type": "string"
                }
              },
              "X-ObjectsGrid-SessionID": {
                "description": "If your request contained this header, it will be included in the response",
                "schema": {
                  "type": "string"
                }
              },
              "ETag": {
                "description": "The object version. Send it in the If-Match header to update, patch or delete this exact version",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "https://objectsgrid.com/.well-known/objects-catalog/Webhook/v1/schema.json"
                }
              }
            }
          },
          "400": {
            "description": "Bad request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "https://objectsgrid.com/.well-known/objects-catalog/ErrorResponse/v1/schema.json"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "https://objectsgrid.com/.well-known/objects-catalog/ErrorResponse/v1/schema.json"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "https://objectsgrid.com/.well-known/objects-catalog/ErrorResponse/v1/schema.json"
                }
              }
            }
          },
          "412": {
            "description": "Precondition Failed - the object was modified since the version in the If-Match header",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "https://objectsgrid.com/.well-known/objects-catalog/ErrorResponse/v1/schema.json"
                }
              }
            }
          },
          "429": {
            "description": "Too Many Requests",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "https://objectsgrid.com/.well-known/objects-catalog/ErrorResponse/v1/schema.json"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "https://objectsgrid.com/.well-known/objects-catalog/ErrorResponse/v1/schema.json"
                }
              }
            }
          }
        }
      },
      "patch": {
        "summary": "Patch Object",
        "operationId": "patch",
        "security": [
          {
            "accessTokenAuth": [

            ]
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "const": "webhooks-config"
            },
            "description": "ID of the object to update"
          },
          {
            "in": "header",
            "name": "X-ObjectsGrid-AccessPoint",
            "description": "EU or US depending on where your Organization Account is located",
            "schema": {
              "type": "string",
              "enum": [
                "EU",
                "US"
              ]
            },
            "required": true
          },
          {
            "in": "header",
            "name": "If-Match",
            "description": "The ETag of the object version being modified, as returned by the Retrieve, Create, Update or Patch operations.\nIf the object has been modified since that version, the request fails with 412 Precondition Failed.\n",
            "schema": {
              "type": "string"
            },
            "required": false
          },
          {
            "in": "header",
            "name": "X-ObjectsGrid-RestApiVersion",
            "description": "This header allows targeting an API version.\nIf you want to target the latest API version set its value to 'latest'\nIf you want to target the latest stable API version set its value to 'stable'\n",
            "schema": {
              "type": "string"
            },
            "required": false
          },
          {
            "in": "header",
            "name": "X-ObjectsGrid-SessionID",
            "description": "This header allows you to provide a Session ID to be traced through the request stack and returned in the response.\n",
            "schema": {
              "type": "string"
            },
            "required": false
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/merge-patch+json": {
              "schema": {
                "type": "object"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successfully patched the object",
            "headers": {
              "X-ObjectsGrid-CorrelationID": {
                "description": "The Correlation ID is a unique value generated by ObjectsGrid and used for troubleshooting issues",
                "schema": {
                  "type": "string"
                }
              },
              "X-ObjectsGrid-SessionID": {
                "description": "If your request contained this header, it will be included in the response",
                "schema": {
                  "type": "string"
                }
              },
              "ETag": {
                "description": "The object version. Send it in the If-Match header to update, patch or delete this exact version",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "https://objectsgrid.com/.well-known/objects-catalog/Webhook/v1/schema.json"
                }
              }
            }
          },
          "400": {
            "description": "Bad request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "https://objectsgrid.com/.well-known/objects-catalog/ErrorResponse/v1/schema.json"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "https://objectsgrid.com/.well-known/objects-catalog/ErrorResponse/v1/schema.json"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "https://objectsgrid.com/.well-known/objects-catalog/ErrorResponse/v1/schema.json"
                }
              }
            }
          },
          "412": {
            "description": "Precondition Failed - the object was modified since the version in the If-Match header",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "https://objectsgrid.com/.well-known/objects-catalog/ErrorResponse/v1/schema.json"
                }
              }
            }
          },
          "429": {
            "description": "Too Many Requests",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "https://objectsgrid.com/.well-known/objects-catalog/ErrorResponse/v1/schema.json"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "https://objectsgrid.com/.well-known/objects-catalog/ErrorResponse/v1/schema.json"
                }
              }
            }
          }
        }
      }
    }
  },
  "webhooks": {
    "sendEvent": {
      "post": {
        "summary": "Deliver an ObjectsGrid event to the subscriber endpoint",
        "operationId": "sendEvent",
        "description": "ObjectsGrid delivers a CloudEvent to a subscriber's\nconfigured HTTPS endpoint.\n\nRequests are authenticated using an RS256-signed JWT\nprovided in the Authorization header.\n\nThe JWT audience (aud) contains the subscriber's\nOrganizationAccount ID.\n\nThe subscriber validates the JWT using ObjectsGrid's\npublished JWKS.\n\nEvent delivery is at least once. Subscribers should\nuse the CloudEvent id for event deduplication.\n",
        "security": [
          {
            "EventJWT": [

            ]
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/cloudevents+json": {
              "schema": {
                "$ref": "#/components/schemas/CloudEvent"
              }
            }
          }
        },
        "responses": {
          "2XX": {
            "description": "Event successfully received or accepted"
          },
          "400": {
            "description": "Invalid event payload"
          },
          "401": {
            "description": "Authentication failed"
          },
          "429": {
            "description": "Subscriber rate limit exceeded"
          },
          "500": {
            "description": "Subscriber processing failure"
          },
          "503": {
            "description": "Subscriber temporarily unavailable"
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "CloudEvent": {
        "type": "object",
        "description": "A CloudEvents 1.0 event in structured JSON mode, as ObjectsGrid delivers it to a webhook endpoint.\nThe written object is JSON in data (never data_base64). Attributes not listed here may be added;\nsubscribers ignore the ones they don't know.\nTwo events are about the OrganizationAccount's spending cap rather than an object: MonthlyQuotaApproaching\n(80, 85, 90 and 95% of monthlyQuota used) and MonthlyQuotaReached (100%: requests now get 429). Their data is a\nMonthlyQuotaNotice, their source https://apis.objectsgrid.com/organizationaccounts, and they carry no\nobjecttype, objectversion or operationname.\n",
        "externalDocs": {
          "description": "CloudEvents 1.0 specification",
          "url": "https://github.com/cloudevents/spec/blob/v1.0.2/cloudevents/spec.md"
        },
        "required": [
          "specversion",
          "id",
          "source",
          "type"
        ],
        "properties": {
          "specversion": {
            "type": "string",
            "const": "1.0"
          },
          "id": {
            "type": "string",
            "description": "Unique per event and the same on every redelivery; use it to deduplicate."
          },
          "source": {
            "type": "string",
            "format": "uri",
            "description": "The API of the object's type.",
            "examples": [
              "https://apis.objectsgrid.com/products"
            ]
          },
          "type": {
            "type": "string",
            "description": "The object type and operation, or MonthlyQuotaApproaching / MonthlyQuotaReached; one of the WebhooksEventsEnumeration values.",
            "examples": [
              "ProductCreated"
            ]
          },
          "datacontenttype": {
            "type": "string",
            "const": "application/json"
          },
          "time": {
            "type": "string",
            "format": "date-time",
            "description": "When the change happened."
          },
          "data": {
            "type": "object",
            "description": "The object as stored after the write; for a delete, the deleted object. For MonthlyQuotaApproaching and MonthlyQuotaReached, a MonthlyQuotaNotice (https://objectsgrid.com/.well-known/objects-catalog/MonthlyQuotaNotice/v1/schema.json)."
          },
          "correlationid": {
            "type": "string",
            "description": "The X-ObjectsGrid-CorrelationID of the request that made the change."
          },
          "orgacctid": {
            "type": "string",
            "description": "The OrganizationAccount ID, the same as the delivery JWT's aud."
          },
          "objecttype": {
            "type": "string",
            "description": "The object's type, e.g. Product."
          },
          "objectversion": {
            "type": "string",
            "description": "The object's version after the write; versions of one object increase."
          },
          "operationname": {
            "type": "string",
            "description": "The operation that made the change, e.g. CreateProduct."
          },
          "href": {
            "type": "string",
            "format": "uri",
            "description": "The event's URL."
          },
          "publishedtime": {
            "type": "string",
            "format": "date-time",
            "description": "When the event was published."
          },
          "environment": {
            "type": "string",
            "description": "The environment, test or prod."
          },
          "accesspoint": {
            "type": "string",
            "description": "The access point, eu or us."
          },
          "appname": {
            "type": "string",
            "description": "The service that published the event."
          },
          "traceparent": {
            "type": "string",
            "description": "W3C Trace Context of the request, when it was traced."
          }
        }
      }
    },
    "securitySchemes": {
      "accessTokenAuth": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "JWT",
        "description": "An ObjectsGrid access token (a JWT), sent as 'Authorization: Bearer <token>': from POST /oauth2/token, valid 1 hour, or an API key: a service account's from the bootstrap of an Organization Account created without signing in, valid 90 days; a public service account's (POST /serviceaccounts/{id}/apikey, or the bootstrap's anonymous one), without expiry, until its account is disabled or deleted."
      },
      "EventJWT": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "JWT",
        "description": "JWT signed by ObjectsGrid using RS256.\n\nRequired claims:\n- iss: https://objectsgrid.com\n- aud: Subscriber OrganizationAccount ID\n- iat: Issued-at timestamp\n- exp: Expiration timestamp (5 minutes after issuance)\n- jti: Unique JWT identifier per delivery attempt\n\nThe JWT header contains kid, identifying the\npublic key used for signature verification.\n\nSubscribers must validate the RS256 signature,\nissuer, audience, and expiration.\n\nJWKS:\nhttps://objectsgrid.com/.well-known/objects-catalog/Webhook/jwks.json\n"
      }
    }
  }
}
