Platform Events API

Event-driven architecture API for publishing and subscribing to custom events for app integration. Supports defining custom event channels with schema for loosely coupled systems.

OpenAPI Specification

salesforce-sales-cloud-platform-events-api-openapi.yml Raw ↑
openapi: 3.1.0
info:
  title: Salesforce Sales Cloud Salesforce Analytics REST Change Events Platform Events API
  description: Access Salesforce reports, dashboards, and analytics data programmatically. Enables embedding analytics into custom applications, automating report generation, running reports synchronously or asynchronously, and managing dashboard components and filters.
  version: 59.0.0
  termsOfService: https://www.salesforce.com/company/legal/agreements/
  contact:
    name: Salesforce Developer Support
    url: https://developer.salesforce.com/
  license:
    name: Salesforce Master Subscription Agreement
    url: https://www.salesforce.com/company/legal/agreements/
servers:
- url: https://{instance}.salesforce.com/services/data/v59.0/analytics
  description: Salesforce Production or Developer Edition
  variables:
    instance:
      default: yourInstance
      description: Your Salesforce instance identifier
security:
- oauth2: []
- bearerAuth: []
tags:
- name: Platform Events
  description: Publish and describe platform events
paths:
  /sobjects/{eventApiName}:
    get:
      operationId: describePlatformEvent
      summary: Salesforce Sales Cloud Describe a platform event
      description: Retrieves metadata about the specified platform event including its fields, label, and API name. The event API name uses the __e suffix (e.g., Order_Event__e).
      tags:
      - Platform Events
      parameters:
      - $ref: '#/components/parameters/eventApiName'
      responses:
        '200':
          description: Successfully retrieved event metadata
          content:
            application/json:
              schema:
                type: object
                properties:
                  objectDescribe:
                    type: object
                    properties:
                      name:
                        type: string
                      label:
                        type: string
                      custom:
                        type: boolean
                      fields:
                        type: array
                        items:
                          type: object
                          properties:
                            name:
                              type: string
                            label:
                              type: string
                            type:
                              type: string
                            length:
                              type: integer
                  recentItems:
                    type: array
                    items:
                      type: object
        '401':
          $ref: '#/components/responses/Unauthorized'
        '404':
          $ref: '#/components/responses/NotFound'
    post:
      operationId: publishPlatformEvent
      summary: Salesforce Sales Cloud Publish a platform event
      description: Publishes a single platform event message by inserting an sObject record for the event type. The event API name uses the __e suffix. Include the event's custom fields in the request body.
      tags:
      - Platform Events
      parameters:
      - $ref: '#/components/parameters/eventApiName'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              additionalProperties: true
              description: Event field name-value pairs
      responses:
        '201':
          description: Event published successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PublishResult'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
  /sobjects/{eventApiName}/describe:
    get:
      operationId: describePlatformEventFull
      summary: Salesforce Sales Cloud Get full platform event metadata
      description: Retrieves complete metadata about the specified platform event including all fields, their types, lengths, and other attributes.
      tags:
      - Platform Events
      parameters:
      - $ref: '#/components/parameters/eventApiName'
      responses:
        '200':
          description: Successfully retrieved full event metadata
          content:
            application/json:
              schema:
                type: object
        '401':
          $ref: '#/components/responses/Unauthorized'
        '404':
          $ref: '#/components/responses/NotFound'
components:
  parameters:
    eventApiName:
      name: eventApiName
      in: path
      required: true
      description: The API name of the platform event (e.g., Order_Event__e)
      schema:
        type: string
  responses:
    BadRequest:
      description: Invalid request
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    Unauthorized:
      description: Authentication failed
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    NotFound:
      description: Resource not found
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
  schemas:
    ErrorResponse:
      type: array
      items:
        $ref: '#/components/schemas/ApiError'
    ApiError:
      type: object
      properties:
        statusCode:
          type: string
        message:
          type: string
        fields:
          type: array
          items:
            type: string
    PublishResult:
      type: object
      properties:
        id:
          type: string
          description: The event message ID
        success:
          type: boolean
        errors:
          type: array
          items:
            $ref: '#/components/schemas/ApiError'
  securitySchemes:
    oauth2:
      type: oauth2
      description: Salesforce OAuth 2.0 authentication
      flows:
        authorizationCode:
          authorizationUrl: https://login.salesforce.com/services/oauth2/authorize
          tokenUrl: https://login.salesforce.com/services/oauth2/token
          scopes:
            api: Access and manage your Salesforce data
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: OAuth 2.0 Access Token
externalDocs:
  description: Salesforce Reports and Dashboards REST API Developer Guide
  url: https://developer.salesforce.com/docs/atlas.en-us.api_analytics.meta/api_analytics/sforce_analytics_rest_api_intro.htm