# Sync outlet (upsert)

> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://apidocs.cata.sg/pos-integration-service-api/api/v-1/outlets/sync/llms.txt.
> For full documentation content, see https://apidocs.cata.sg/pos-integration-service-api/api/v-1/outlets/sync/llms-full.txt.

POST http://localhost:8080/api/v1/outlets/sync
Content-Type: application/json

Upsert an outlet by `externalId`. If an outlet with the given external ID exists, it is
updated; otherwise a new outlet is created. Provider is validated via `X-Provider` header
against tenant settings.

**Idempotent:** calling with the same payload again produces the same result.


Reference: https://apidocs.cata.sg/pos-integration-service-api/api/v-1/outlets/sync/sync-outlet-upsert

## OpenAPI Specification

```yaml
openapi: 3.1.0
info:
  title: collection
  version: 1.0.0
paths:
  /api/v1/outlets/sync:
    post:
      operationId: sync-outlet-upsert
      summary: Sync outlet (upsert)
      description: >
        Upsert an outlet by `externalId`. If an outlet with the given external
        ID exists, it is

        updated; otherwise a new outlet is created. Provider is validated via
        `X-Provider` header

        against tenant settings.


        **Idempotent:** calling with the same payload again produces the same
        result.
      tags:
        - >-
          subpackage_api.subpackage_api/v1.subpackage_api/v1/outlets.subpackage_api/v1/outlets/sync
      parameters:
        - name: X-Api-Key
          in: header
          required: true
          schema:
            type: string
        - name: X-Tenant-ID
          in: header
          description: Tenant identifier
          required: false
          schema:
            type: string
        - name: X-Provider
          in: header
          description: POS provider name (validated against tenant settings)
          required: false
          schema:
            type: string
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: >-
                  #/components/schemas/api_v1_outlets_sync_Sync outlet
                  (upsert)_Response_200
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: >-
                  #/components/schemas/PostApiV1OutletsSyncRequestBadRequestError
        '403':
          description: Forbidden
          content:
            application/json:
              schema:
                description: Any type
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                externalId:
                  type: string
                name:
                  type: string
                channelLinkId:
                  type: string
                address:
                  $ref: >-
                    #/components/schemas/ApiV1OutletsSyncPostRequestBodyContentApplicationJsonSchemaAddress
                contact:
                  $ref: >-
                    #/components/schemas/ApiV1OutletsSyncPostRequestBodyContentApplicationJsonSchemaContact
                timezone:
                  type: string
              required:
                - externalId
                - name
                - channelLinkId
                - address
                - contact
                - timezone
servers:
  - url: http://localhost:8080
components:
  schemas:
    ApiV1OutletsSyncPostRequestBodyContentApplicationJsonSchemaAddress:
      type: object
      properties:
        street1:
          type: string
        city:
          type: string
        postalCode:
          type: string
        country:
          type: string
      required:
        - street1
        - city
        - postalCode
        - country
      title: ApiV1OutletsSyncPostRequestBodyContentApplicationJsonSchemaAddress
    ApiV1OutletsSyncPostRequestBodyContentApplicationJsonSchemaContact:
      type: object
      properties:
        phone:
          type: string
        email:
          type: string
          format: email
      required:
        - phone
        - email
      title: ApiV1OutletsSyncPostRequestBodyContentApplicationJsonSchemaContact
    ApiV1OutletsSyncPostResponsesContentApplicationJsonSchemaOutletAddress:
      type: object
      properties:
        street1:
          type: string
        street2:
          type: string
        city:
          type: string
        state:
          type: string
        postalCode:
          type: string
        country:
          type: string
        latitude:
          type: number
          format: double
        longitude:
          type: number
          format: double
      required:
        - street1
        - street2
        - city
        - state
        - postalCode
        - country
        - latitude
        - longitude
      title: ApiV1OutletsSyncPostResponsesContentApplicationJsonSchemaOutletAddress
    ApiV1OutletsSyncPostResponsesContentApplicationJsonSchemaOutletContact:
      type: object
      properties:
        email:
          type: string
          format: email
        phone:
          type: string
        website:
          type: string
        contactName:
          type: string
      required:
        - email
        - phone
        - website
        - contactName
      title: ApiV1OutletsSyncPostResponsesContentApplicationJsonSchemaOutletContact
    ApiV1OutletsSyncPostResponsesContentApplicationJsonSchemaOutletOpeningHoursItems:
      type: object
      properties:
        dayOfWeek:
          type: integer
        openTime:
          type: string
        closeTime:
          type: string
        isClosed:
          type: boolean
      required:
        - dayOfWeek
        - openTime
        - closeTime
        - isClosed
      title: >-
        ApiV1OutletsSyncPostResponsesContentApplicationJsonSchemaOutletOpeningHoursItems
    ApiV1OutletsSyncPostResponsesContentApplicationJsonSchemaOutletCapabilities:
      type: object
      properties:
        acceptsDelivery:
          type: boolean
        acceptsPickup:
          type: boolean
        acceptsDineIn:
          type: boolean
      required:
        - acceptsDelivery
        - acceptsPickup
        - acceptsDineIn
      title: >-
        ApiV1OutletsSyncPostResponsesContentApplicationJsonSchemaOutletCapabilities
    ApiV1OutletsSyncPostResponsesContentApplicationJsonSchemaOutlet:
      type: object
      properties:
        id:
          type: string
        name:
          type: string
        status:
          type: string
        externalId:
          type: string
        internalName:
          type: string
        slug:
          type: string
        refCode:
          type: string
        imageUrl:
          type: string
          format: uri
        address:
          $ref: >-
            #/components/schemas/ApiV1OutletsSyncPostResponsesContentApplicationJsonSchemaOutletAddress
        contact:
          $ref: >-
            #/components/schemas/ApiV1OutletsSyncPostResponsesContentApplicationJsonSchemaOutletContact
        isOpen:
          type: boolean
        isBusy:
          type: boolean
        visible:
          type: boolean
        timezone:
          type: string
        openingHours:
          type: array
          items:
            $ref: >-
              #/components/schemas/ApiV1OutletsSyncPostResponsesContentApplicationJsonSchemaOutletOpeningHoursItems
        capabilities:
          $ref: >-
            #/components/schemas/ApiV1OutletsSyncPostResponsesContentApplicationJsonSchemaOutletCapabilities
        locationId:
          type: string
        channelLinkId:
          type: string
        showStartDatetime:
          type: string
          format: date-time
        createdAt:
          type: string
          format: date-time
        updatedAt:
          type: string
          format: date-time
      required:
        - id
        - name
        - status
        - externalId
        - internalName
        - slug
        - refCode
        - imageUrl
        - address
        - contact
        - isOpen
        - isBusy
        - visible
        - timezone
        - openingHours
        - capabilities
        - locationId
        - channelLinkId
        - showStartDatetime
        - createdAt
        - updatedAt
      title: ApiV1OutletsSyncPostResponsesContentApplicationJsonSchemaOutlet
    api_v1_outlets_sync_Sync outlet (upsert)_Response_200:
      type: object
      properties:
        action:
          type: string
        outlet:
          $ref: >-
            #/components/schemas/ApiV1OutletsSyncPostResponsesContentApplicationJsonSchemaOutlet
      required:
        - action
        - outlet
      title: api_v1_outlets_sync_Sync outlet (upsert)_Response_200
    ApiV1OutletsSyncPostResponsesContentApplicationJsonSchemaError:
      type: object
      properties:
        code:
          type: integer
        message:
          type: string
        details:
          type: string
        field:
          type: string
      required:
        - code
        - message
        - details
        - field
      title: ApiV1OutletsSyncPostResponsesContentApplicationJsonSchemaError
    PostApiV1OutletsSyncRequestBadRequestError:
      type: object
      properties:
        error:
          $ref: >-
            #/components/schemas/ApiV1OutletsSyncPostResponsesContentApplicationJsonSchemaError
      required:
        - error
      title: PostApiV1OutletsSyncRequestBadRequestError
  securitySchemes:
    apiKeyAuth:
      type: apiKey
      in: header
      name: X-Api-Key

```

## SDK Code Examples

```python api_v1_outlets_sync_Sync outlet (upsert)_example
import requests

url = "http://localhost:8080/api/v1/outlets/sync"

payload = {
    "externalId": "store-001",
    "name": "Golden Dragon Restaurant",
    "channelLinkId": "ch-link-001",
    "address": {
        "street1": "123 Main St",
        "city": "Singapore",
        "postalCode": "123456",
        "country": "SG"
    },
    "contact": {
        "phone": "+65 1234 5678",
        "email": "info@goldendragon.sg"
    },
    "timezone": "Asia/Singapore"
}
headers = {
    "X-Tenant-ID": "string",
    "X-Provider": "cata",
    "X-Api-Key": "<apiKey>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```javascript api_v1_outlets_sync_Sync outlet (upsert)_example
const url = 'http://localhost:8080/api/v1/outlets/sync';
const options = {
  method: 'POST',
  headers: {
    'X-Tenant-ID': 'string',
    'X-Provider': 'cata',
    'X-Api-Key': '<apiKey>',
    'Content-Type': 'application/json'
  },
  body: '{"externalId":"store-001","name":"Golden Dragon Restaurant","channelLinkId":"ch-link-001","address":{"street1":"123 Main St","city":"Singapore","postalCode":"123456","country":"SG"},"contact":{"phone":"+65 1234 5678","email":"info@goldendragon.sg"},"timezone":"Asia/Singapore"}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go api_v1_outlets_sync_Sync outlet (upsert)_example
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "http://localhost:8080/api/v1/outlets/sync"

	payload := strings.NewReader("{\n  \"externalId\": \"store-001\",\n  \"name\": \"Golden Dragon Restaurant\",\n  \"channelLinkId\": \"ch-link-001\",\n  \"address\": {\n    \"street1\": \"123 Main St\",\n    \"city\": \"Singapore\",\n    \"postalCode\": \"123456\",\n    \"country\": \"SG\"\n  },\n  \"contact\": {\n    \"phone\": \"+65 1234 5678\",\n    \"email\": \"info@goldendragon.sg\"\n  },\n  \"timezone\": \"Asia/Singapore\"\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("X-Tenant-ID", "string")
	req.Header.Add("X-Provider", "cata")
	req.Header.Add("X-Api-Key", "<apiKey>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby api_v1_outlets_sync_Sync outlet (upsert)_example
require 'uri'
require 'net/http'

url = URI("http://localhost:8080/api/v1/outlets/sync")

http = Net::HTTP.new(url.host, url.port)

request = Net::HTTP::Post.new(url)
request["X-Tenant-ID"] = 'string'
request["X-Provider"] = 'cata'
request["X-Api-Key"] = '<apiKey>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"externalId\": \"store-001\",\n  \"name\": \"Golden Dragon Restaurant\",\n  \"channelLinkId\": \"ch-link-001\",\n  \"address\": {\n    \"street1\": \"123 Main St\",\n    \"city\": \"Singapore\",\n    \"postalCode\": \"123456\",\n    \"country\": \"SG\"\n  },\n  \"contact\": {\n    \"phone\": \"+65 1234 5678\",\n    \"email\": \"info@goldendragon.sg\"\n  },\n  \"timezone\": \"Asia/Singapore\"\n}"

response = http.request(request)
puts response.read_body
```

```java api_v1_outlets_sync_Sync outlet (upsert)_example
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("http://localhost:8080/api/v1/outlets/sync")
  .header("X-Tenant-ID", "string")
  .header("X-Provider", "cata")
  .header("X-Api-Key", "<apiKey>")
  .header("Content-Type", "application/json")
  .body("{\n  \"externalId\": \"store-001\",\n  \"name\": \"Golden Dragon Restaurant\",\n  \"channelLinkId\": \"ch-link-001\",\n  \"address\": {\n    \"street1\": \"123 Main St\",\n    \"city\": \"Singapore\",\n    \"postalCode\": \"123456\",\n    \"country\": \"SG\"\n  },\n  \"contact\": {\n    \"phone\": \"+65 1234 5678\",\n    \"email\": \"info@goldendragon.sg\"\n  },\n  \"timezone\": \"Asia/Singapore\"\n}")
  .asString();
```

```php api_v1_outlets_sync_Sync outlet (upsert)_example
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'http://localhost:8080/api/v1/outlets/sync', [
  'body' => '{
  "externalId": "store-001",
  "name": "Golden Dragon Restaurant",
  "channelLinkId": "ch-link-001",
  "address": {
    "street1": "123 Main St",
    "city": "Singapore",
    "postalCode": "123456",
    "country": "SG"
  },
  "contact": {
    "phone": "+65 1234 5678",
    "email": "info@goldendragon.sg"
  },
  "timezone": "Asia/Singapore"
}',
  'headers' => [
    'Content-Type' => 'application/json',
    'X-Api-Key' => '<apiKey>',
    'X-Provider' => 'cata',
    'X-Tenant-ID' => 'string',
  ],
]);

echo $response->getBody();
```

```csharp api_v1_outlets_sync_Sync outlet (upsert)_example
using RestSharp;

var client = new RestClient("http://localhost:8080/api/v1/outlets/sync");
var request = new RestRequest(Method.POST);
request.AddHeader("X-Tenant-ID", "string");
request.AddHeader("X-Provider", "cata");
request.AddHeader("X-Api-Key", "<apiKey>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"externalId\": \"store-001\",\n  \"name\": \"Golden Dragon Restaurant\",\n  \"channelLinkId\": \"ch-link-001\",\n  \"address\": {\n    \"street1\": \"123 Main St\",\n    \"city\": \"Singapore\",\n    \"postalCode\": \"123456\",\n    \"country\": \"SG\"\n  },\n  \"contact\": {\n    \"phone\": \"+65 1234 5678\",\n    \"email\": \"info@goldendragon.sg\"\n  },\n  \"timezone\": \"Asia/Singapore\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift api_v1_outlets_sync_Sync outlet (upsert)_example
import Foundation

let headers = [
  "X-Tenant-ID": "string",
  "X-Provider": "cata",
  "X-Api-Key": "<apiKey>",
  "Content-Type": "application/json"
]
let parameters = [
  "externalId": "store-001",
  "name": "Golden Dragon Restaurant",
  "channelLinkId": "ch-link-001",
  "address": [
    "street1": "123 Main St",
    "city": "Singapore",
    "postalCode": "123456",
    "country": "SG"
  ],
  "contact": [
    "phone": "+65 1234 5678",
    "email": "info@goldendragon.sg"
  ],
  "timezone": "Asia/Singapore"
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "http://localhost:8080/api/v1/outlets/sync")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```