# Database as a Write Proxy to another system

For example, Stacksync allows PostgreSQL to act as a write proxy for systems like Salesforce, enabling teams to batch large volumes of changes, significantly reduce API calls, stay within rate limits, and minimize load on Salesforce.

Stacksync supports upsert-based syncs between a source application and a destination application using a custom-managed unique identifier, rather than the source or destination’s native primary key (for example, a Salesforce ID). Concretely, this means each write operation will create a new record or update an existing one in the destination based on that custom identifier, regardless of the destination’s internal primary key.

This allows the source system to act as a **write proxy** for the destination while preserving record uniqueness based on the custom identifier.

### Setup

1. **Prepare fields in the destination app**\
   Ensure that the customer-managed unique identifier, as well as every field you plan to populate from the source app, exists and is properly configured in the destination app (type, format, and uniqueness where applicable).
2. **Create the sync in StackSync**
   * Open the StackSync app and create a new sync.
   * Select the source app and table you want to sync from.
   * Select the destination app and object you want to sync to.
3. **Select columns to sync**\
   In the list of columns to sync, include only:
   * The customer-managed unique identifier.
   * The fields you want to populate in the destination app from the source app.
4. **Configure sync direction**\
   Set the sync direction to two-way sync so the customer-managed unique identifier is available in the source app and in Postgres. You are responsible for performing upserts in the source app using this identifier, and StackSync is responsible for propagating the updated fields from the source (via Postgres) into the destination app.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.stacksync.com/two-way-sync/guides/database-as-a-write-proxy-to-another-system.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
