---
schema_version: "1"
id: c2bbb759897362a6b96b48015e56a2759a9c416661b28a1d4ab1ad5c30e72d2b
title: Publish RPC Method
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/event-bus/pub-sub-api/references/publish-rpc.md
canonical_url: https://developer.salesforce.com/docs/platform/pub-sub-api/references/methods/publish-rpc.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: 76cb095bc399e747dfa9618f3c1b6dd77a61e867423d984aaed97e7f2fca84b0
products:
  - Pub/Sub API
  - Event Bus Docs
---
# Publish RPC Method

The `Publish` method is a unary RPC, which means that it sends only one request and receives only one response. It synchronously publishes the batch of events in PublishRequest to an event bus topic. After publishing the event messages, the server sends a response to the client. Use the `Publish` method if you want to know the status of a publish operation before publishing the next batch of event messages.

```
rpc Publish (PublishRequest) returns (PublishResponse);
```

The PublishResponse holds a PublishResult for each event published that indicates success or failure of the publish operation. A successful status means that the event was published and is in the event bus. A failed status means that the event failed to publish.

## Publishing Required Fields

The `Publish` method doesn’t enforce the presence of required custom event fields in the event payload. If you publish an event without including a required custom field, the publish call succeeds and the received event contains the field with a null value. For system fields, the `CreatedDate` and `CreatedById` fields are required in the event payload. If you publish an event without these system fields, the call fails.

## Order of Events

If you publish a batch of events, the order of results in PublishResponse corresponds to the order of the events in the publish request. You can correlate each successful or failed result with the corresponding event in the publish request.

## Retry Publishing Failed Events

You can retry publishing one or more failed events. You can match a publish result with the corresponding event in the publish request.

If you don’t want to rely on the order of events published and received, you can use the event `id` field and `correlationKey` field of PublishResult. The process is similar to the one described for the `PublishStream` RPC method. For more information, see [PublishStream RPC Method](https://developer.salesforce.com/docs/platform/pub-sub-api/references/methods/publishstream-rpc.html).

For more information about the fields in PublishRequest and PublishResponse, see the [Pub/Sub API proto file](https://github.com/forcedotcom/pub-sub-api/blob/main/pubsub_api.proto).
