# Batch publish menus (full-replace)

> 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/menus/publish/llms.txt.
> For full documentation content, see https://apidocs.cata.sg/pos-integration-service-api/api/v-1/menus/publish/llms-full.txt.

POST http://localhost:8080/api/v1/menus/publish
Content-Type: application/json

Publish multiple draft menus to multiple outlets with **full-replace semantics**.

For each target outlet, this endpoint:
1. Soft-deletes ALL existing live menus for the outlet
2. Creates new live menus from the selected drafts (one per draft per outlet)
3. Records publish logs

**Full-replace behavior:** Publishing replaces all existing live menus for the target outlets.
To keep multiple menus on an outlet, publish them together in one request.
One transaction per outlet — if one outlet fails, others may still succeed.


Reference: https://apidocs.cata.sg/pos-integration-service-api/api/v-1/menus/publish/batch-publish-menus-full-replace

## OpenAPI Specification

```yaml
openapi: 3.1.0
info:
  title: collection
  version: 1.0.0
paths:
  /api/v1/menus/publish:
    post:
      operationId: batch-publish-menus-full-replace
      summary: Batch publish menus (full-replace)
      description: >
        Publish multiple draft menus to multiple outlets with **full-replace
        semantics**.


        For each target outlet, this endpoint:

        1. Soft-deletes ALL existing live menus for the outlet

        2. Creates new live menus from the selected drafts (one per draft per
        outlet)

        3. Records publish logs


        **Full-replace behavior:** Publishing replaces all existing live menus
        for the target outlets.

        To keep multiple menus on an outlet, publish them together in one
        request.

        One transaction per outlet — if one outlet fails, others may still
        succeed.
      tags:
        - >-
          subpackage_api.subpackage_api/v1.subpackage_api/v1/menus.subpackage_api/v1/menus/publish
      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
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: >-
                  #/components/schemas/api_v1_menus_publish_Batch publish menus
                  (full-replace)_Response_200
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: >-
                  #/components/schemas/PostApiV1MenusPublishRequestBadRequestError
        '404':
          description: Not Found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PostApiV1MenusPublishRequestNotFoundError'
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                draftIds:
                  type: array
                  items:
                    type: integer
                outletIds:
                  type: array
                  items:
                    type: string
              required:
                - draftIds
                - outletIds
servers:
  - url: http://localhost:8080
components:
  schemas:
    ApiV1MenusPublishPostResponsesContentApplicationJsonSchemaPublishedMenusItems:
      type: object
      properties:
        outletId:
          type: string
        menuId:
          type: integer
      required:
        - outletId
        - menuId
      title: >-
        ApiV1MenusPublishPostResponsesContentApplicationJsonSchemaPublishedMenusItems
    api_v1_menus_publish_Batch publish menus (full-replace)_Response_200:
      type: object
      properties:
        code:
          type: integer
        isSuccess:
          type: boolean
        message:
          type: string
        publishedMenus:
          type: array
          items:
            $ref: >-
              #/components/schemas/ApiV1MenusPublishPostResponsesContentApplicationJsonSchemaPublishedMenusItems
      required:
        - code
        - isSuccess
        - message
        - publishedMenus
      title: api_v1_menus_publish_Batch publish menus (full-replace)_Response_200
    ApiV1MenusPublishPostResponsesContentApplicationJsonSchemaError:
      type: object
      properties:
        code:
          type: integer
        message:
          type: string
        details:
          type: string
        field:
          type: string
      required:
        - code
        - message
        - details
        - field
      title: ApiV1MenusPublishPostResponsesContentApplicationJsonSchemaError
    PostApiV1MenusPublishRequestBadRequestError:
      type: object
      properties:
        error:
          $ref: >-
            #/components/schemas/ApiV1MenusPublishPostResponsesContentApplicationJsonSchemaError
      required:
        - error
      title: PostApiV1MenusPublishRequestBadRequestError
    PostApiV1MenusPublishRequestNotFoundError:
      type: object
      properties:
        error:
          $ref: >-
            #/components/schemas/ApiV1MenusPublishPostResponsesContentApplicationJsonSchemaError
      required:
        - error
      title: PostApiV1MenusPublishRequestNotFoundError
  securitySchemes:
    apiKeyAuth:
      type: apiKey
      in: header
      name: X-Api-Key

```

## SDK Code Examples

```python api_v1_menus_publish_Batch publish menus (full-replace)_example
import requests

url = "http://localhost:8080/api/v1/menus/publish"

payload = {
    "draftIds": [6464, 8378],
    "outletIds": ["string", "string"]
}
headers = {
    "X-Tenant-ID": "string",
    "X-Api-Key": "<apiKey>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript api_v1_menus_publish_Batch publish menus (full-replace)_example
const url = 'http://localhost:8080/api/v1/menus/publish';
const options = {
  method: 'POST',
  headers: {
    'X-Tenant-ID': 'string',
    'X-Api-Key': '<apiKey>',
    'Content-Type': 'application/json'
  },
  body: '{"draftIds":[6464,8378],"outletIds":["string","string"]}'
};

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

```go api_v1_menus_publish_Batch publish menus (full-replace)_example
package main

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

func main() {

	url := "http://localhost:8080/api/v1/menus/publish"

	payload := strings.NewReader("{\n  \"draftIds\": [\n    6464,\n    8378\n  ],\n  \"outletIds\": [\n    \"string\",\n    \"string\"\n  ]\n}")

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

	req.Header.Add("X-Tenant-ID", "string")
	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_menus_publish_Batch publish menus (full-replace)_example
require 'uri'
require 'net/http'

url = URI("http://localhost:8080/api/v1/menus/publish")

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

request = Net::HTTP::Post.new(url)
request["X-Tenant-ID"] = 'string'
request["X-Api-Key"] = '<apiKey>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"draftIds\": [\n    6464,\n    8378\n  ],\n  \"outletIds\": [\n    \"string\",\n    \"string\"\n  ]\n}"

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

```java api_v1_menus_publish_Batch publish menus (full-replace)_example
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("http://localhost:8080/api/v1/menus/publish")
  .header("X-Tenant-ID", "string")
  .header("X-Api-Key", "<apiKey>")
  .header("Content-Type", "application/json")
  .body("{\n  \"draftIds\": [\n    6464,\n    8378\n  ],\n  \"outletIds\": [\n    \"string\",\n    \"string\"\n  ]\n}")
  .asString();
```

```php api_v1_menus_publish_Batch publish menus (full-replace)_example
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'http://localhost:8080/api/v1/menus/publish', [
  'body' => '{
  "draftIds": [
    6464,
    8378
  ],
  "outletIds": [
    "string",
    "string"
  ]
}',
  'headers' => [
    'Content-Type' => 'application/json',
    'X-Api-Key' => '<apiKey>',
    'X-Tenant-ID' => 'string',
  ],
]);

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

```csharp api_v1_menus_publish_Batch publish menus (full-replace)_example
using RestSharp;

var client = new RestClient("http://localhost:8080/api/v1/menus/publish");
var request = new RestRequest(Method.POST);
request.AddHeader("X-Tenant-ID", "string");
request.AddHeader("X-Api-Key", "<apiKey>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"draftIds\": [\n    6464,\n    8378\n  ],\n  \"outletIds\": [\n    \"string\",\n    \"string\"\n  ]\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift api_v1_menus_publish_Batch publish menus (full-replace)_example
import Foundation

let headers = [
  "X-Tenant-ID": "string",
  "X-Api-Key": "<apiKey>",
  "Content-Type": "application/json"
]
let parameters = [
  "draftIds": [6464, 8378],
  "outletIds": ["string", "string"]
] as [String : Any]

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

let request = NSMutableURLRequest(url: NSURL(string: "http://localhost:8080/api/v1/menus/publish")! 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()
```