# Sync/upsert a prompt with local content

Sync/upsert a prompt with local content

> Page: https://langwatch.ai/docs/api-reference/prompts/action-sync
> Source: https://github.com/langwatch/langwatch/blob/main/docs/api-reference/prompts/action-sync.mdx
> Index of all pages: https://langwatch.ai/docs/llms.txt

## Endpoint

`POST https://app.langwatch.ai/api/v1/prompts/{id}/sync`

## Authentication

### project_api_key

Project API key for sending traces and accessing project-scoped resources. Format: sk-lw-... (no underscore). Obtain one by creating a project via the Admin API or the LangWatch UI.

```json
{"id":"project_api_key","type":"apiKey","in":"header","name":"X-Auth-Token"}
```

## Parameters

### id (path, required)

```json
{"type":"string"}
```

## Request body (required)

#### application/json

Schema:

```json
{
  "type": "object",
  "properties": {
    "configData": {
      "type": "object",
      "properties": {
        "prompt": {"type":"string"},
        "messages": {
          "default": [],
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "role": {"type":"string","enum":["user","assistant","system"]},
              "content": {"type":"string"}
            },
            "required": ["role","content"]
          }
        },
        "inputs": {
          "default": [],
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "identifier": {"type":"string","minLength":1},
              "type": {
                "type": "string",
                "enum": [
                  "str",
                  "float",
                  "bool",
                  "image",
                  "file",
                  "list",
                  "list[str]",
                  "list[float]",
                  "list[int]",
                  "list[bool]",
                  "dict",
                  "chat_messages"
                ]
              }
            },
            "required": ["identifier","type"]
          }
        },
        "outputs": {
          "minItems": 1,
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "identifier": {"type":"string","minLength":1},
              "type": {"type":"string","enum":["str","float","bool","json_schema"]},
              "json_schema": {
                "type": "object",
                "required": ["type"],
                "additionalProperties": {},
                "properties": {"type":{"type":"string","minLength":1}}
              }
            },
            "required": ["identifier","type"]
          }
        },
        "model": {"type":"string","minLength":1},
        "temperature": {"type":"number"},
        "max_tokens": {"type":"number"},
        "top_p": {"type":"number"},
        "frequency_penalty": {"type":"number"},
        "presence_penalty": {"type":"number"},
        "seed": {"type":"number"},
        "top_k": {"type":"number"},
        "min_p": {"type":"number"},
        "repetition_penalty": {"type":"number"},
        "reasoning": {"type":"string"},
        "reasoning_effort": {"type":"string"},
        "thinkingLevel": {"type":"string"},
        "effort": {"type":"string"},
        "verbosity": {"type":"string"},
        "demonstrations": {
          "type": "object",
          "properties": {
            "id": {"type":"string"},
            "name": {"type":"string"},
            "inline": {
              "type": "object",
              "properties": {
                "records": {
                  "type": "object",
                  "propertyNames": {"type":"string"},
                  "additionalProperties": {"type":"array","items":{}}
                },
                "columnTypes": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "id": {"type":"string"},
                      "name": {"type":"string"},
                      "type": {
                        "type": "string",
                        "enum": [
                          "string",
                          "boolean",
                          "number",
                          "date",
                          "list",
                          "json",
                          "spans",
                          "rag_contexts",
                          "chat_messages",
                          "annotations",
                          "evaluations",
                          "image",
                          "file"
                        ]
                      }
                    },
                    "required": ["name","type"]
                  }
                }
              },
              "required": ["records","columnTypes"]
            }
          }
        },
        "prompting_technique": {
          "type": "object",
          "properties": {
            "type": {
              "type": "string",
              "enum": ["few_shot","in_context","chain_of_thought"]
            },
            "demonstrations": {
              "type": "object",
              "properties": {
                "id": {"type":"string"},
                "name": {"type":"string"},
                "inline": {
                  "type": "object",
                  "properties": {
                    "records": {
                      "type": "object",
                      "propertyNames": {"type":"string"},
                      "additionalProperties": {"type":"array","items":{}}
                    },
                    "columnTypes": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {"type":"string"},
                          "name": {"type":"string"},
                          "type": {
                            "type": "string",
                            "enum": [
                              "string",
                              "boolean",
                              "number",
                              "date",
                              "list",
                              "json",
                              "spans",
                              "rag_contexts",
                              "chat_messages",
                              "annotations",
                              "evaluations",
                              "image",
                              "file"
                            ]
                          }
                        },
                        "required": ["name","type"]
                      }
                    }
                  },
                  "required": ["records","columnTypes"]
                }
              }
            }
          },
          "required": ["type"]
        },
        "response_format": {
          "type": "object",
          "properties": {
            "type": {"type":"string","enum":["json_schema"]},
            "json_schema": {
              "anyOf": [
                {
                  "type": "object",
                  "properties": {
                    "name": {"type":"string"},
                    "schema": {"type":"object","additionalProperties":{}}
                  },
                  "required": ["name","schema"]
                },
                {"type":"null"}
              ]
            }
          },
          "required": ["type","json_schema"]
        }
      },
      "required": ["prompt","outputs","model"]
    },
    "parameters": {
      "type": "object",
      "propertyNames": {"type":"string"},
      "additionalProperties": {}
    },
    "localVersion": {"type":"number","minimum":0},
    "commitMessage": {"type":"string"}
  },
  "required": ["configData"]
}
```

## Request example

```bash
curl --request POST \
  --url 'https://app.langwatch.ai/api/v1/prompts/<id>/sync' \
  --header "X-Auth-Token: $LANGWATCH_API_KEY" \
  --header 'Content-Type: application/json' \
  --data '{"configData":{"prompt":"string","messages":[],"inputs":[],"outputs":[{"identifier":"string","type":"str","json_schema":{"type":"string"}}],"model":"string","temperature":0,"max_tokens":0,"top_p":0,"frequency_penalty":0,"presence_penalty":0,"seed":0,"top_k":0,"min_p":0,"repetition_penalty":0,"reasoning":"string","reasoning_effort":"string","thinkingLevel":"string","effort":"string","verbosity":"string","demonstrations":{"id":"string","name":"string","inline":{"records":{},"columnTypes":[{"id":null,"name":null,"type":null}]}},"prompting_technique":{"type":"few_shot","demonstrations":{"id":"string","name":"string","inline":{"records":{},"columnTypes":[null]}}},"response_format":{"type":"json_schema","json_schema":{"name":"string","schema":{}}}},"parameters":{},"localVersion":0,"commitMessage":"string"}'
```

## Responses

### 200

Sync result

#### application/json

Schema:

```json
{
  "type": "object",
  "properties": {
    "action": {"type":"string","enum":["created","updated","conflict","up_to_date"]},
    "prompt": {
      "type": "object",
      "properties": {
        "id": {"type":"string"},
        "handle": {"type":["string","null"]},
        "scope": {"type":"string","enum":["PROJECT","ORGANIZATION"]},
        "name": {"type":"string"},
        "updatedAt": {"type":"string","format":"date-time"},
        "projectId": {"type":"string"},
        "organizationId": {"type":"string"},
        "versionId": {"type":"string"},
        "authorId": {"type":["string","null"]},
        "version": {"type":"number"},
        "createdAt": {"type":"string","format":"date-time"},
        "commitMessage": {"type":["string","null"]},
        "prompt": {"type":"string"},
        "messages": {
          "default": [],
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "role": {"type":"string","enum":["user","assistant","system"]},
              "content": {"type":"string"}
            },
            "required": ["role","content"],
            "additionalProperties": false
          }
        },
        "inputs": {
          "default": [],
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "identifier": {"type":"string","minLength":1},
              "type": {
                "type": "string",
                "enum": [
                  "str",
                  "float",
                  "bool",
                  "image",
                  "file",
                  "list",
                  "list[str]",
                  "list[float]",
                  "list[int]",
                  "list[bool]",
                  "dict",
                  "chat_messages"
                ]
              }
            },
            "required": ["identifier","type"],
            "additionalProperties": false
          }
        },
        "outputs": {
          "minItems": 1,
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "identifier": {"type":"string","minLength":1},
              "type": {"type":"string","enum":["str","float","bool","json_schema"]},
              "json_schema": {
                "type": "object",
                "required": ["type"],
                "additionalProperties": {},
                "properties": {"type":{"type":"string","minLength":1}}
              }
            },
            "required": ["identifier","type"],
            "additionalProperties": false
          }
        },
        "model": {"type":"string","minLength":1},
        "temperature": {"type":"number"},
        "maxTokens": {"type":"number"},
        "demonstrations": {
          "type": "object",
          "properties": {
            "id": {"type":"string"},
            "name": {"type":"string"},
            "inline": {
              "type": "object",
              "properties": {
                "records": {
                  "type": "object",
                  "propertyNames": {"type":"string"},
                  "additionalProperties": {"type":"array","items":{}}
                },
                "columnTypes": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "id": {"type":"string"},
                      "name": {"type":"string"},
                      "type": {
                        "type": "string",
                        "enum": [
                          "string",
                          "boolean",
                          "number",
                          "date",
                          "list",
                          "json",
                          "spans",
                          "rag_contexts",
                          "chat_messages",
                          "annotations",
                          "evaluations",
                          "image",
                          "file"
                        ]
                      }
                    },
                    "required": ["name","type"],
                    "additionalProperties": false
                  }
                }
              },
              "required": ["records","columnTypes"],
              "additionalProperties": false
            }
          },
          "additionalProperties": false
        },
        "promptingTechnique": {
          "type": "object",
          "properties": {
            "type": {
              "type": "string",
              "enum": ["few_shot","in_context","chain_of_thought"]
            },
            "demonstrations": {
              "type": "object",
              "properties": {
                "id": {"type":"string"},
                "name": {"type":"string"},
                "inline": {
                  "type": "object",
                  "properties": {
                    "records": {
                      "type": "object",
                      "propertyNames": {"type":"string"},
                      "additionalProperties": {"type":"array","items":{}}
                    },
                    "columnTypes": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {"type":"string"},
                          "name": {"type":"string"},
                          "type": {
                            "type": "string",
                            "enum": [
                              "string",
                              "boolean",
                              "number",
                              "date",
                              "list",
                              "json",
                              "spans",
                              "rag_contexts",
                              "chat_messages",
                              "annotations",
                              "evaluations",
                              "image",
                              "file"
                            ]
                          }
                        },
                        "required": ["name","type"],
                        "additionalProperties": false
                      }
                    }
                  },
                  "required": ["records","columnTypes"],
                  "additionalProperties": false
                }
              },
              "additionalProperties": false
            }
          },
          "required": ["type"],
          "additionalProperties": false
        },
        "responseFormat": {
          "type": "object",
          "properties": {
            "type": {"type":"string","enum":["json_schema"]},
            "json_schema": {
              "anyOf": [
                {
                  "type": "object",
                  "properties": {
                    "name": {"type":"string"},
                    "schema": {"type":"object","additionalProperties":{}}
                  },
                  "required": ["name","schema"],
                  "additionalProperties": false
                },
                {"type":"null"}
              ]
            }
          },
          "required": ["type","json_schema"],
          "additionalProperties": false
        },
        "tags": {
          "default": [],
          "type": "array",
          "items": {
            "type": "object",
            "properties": {"name":{"type":"string"},"versionId":{"type":"string"}},
            "required": ["name","versionId"],
            "additionalProperties": false
          }
        },
        "parameters": {
          "default": {},
          "type": "object",
          "propertyNames": {"type":"string"},
          "additionalProperties": {
            "anyOf": [
              {"type":"string"},
              {"type":"number"},
              {"type":"boolean"},
              {"type":"null"},
              {"type":"array","items":{"$recursive":"JsonValue"}},
              {
                "type": "object",
                "propertyNames": {"type":"string"},
                "additionalProperties": {"$recursive":"JsonValue"}
              }
            ]
          }
        }
      },
      "required": [
        "id",
        "handle",
        "scope",
        "name",
        "updatedAt",
        "projectId",
        "organizationId",
        "versionId",
        "version",
        "createdAt",
        "prompt",
        "messages",
        "inputs",
        "outputs",
        "model",
        "tags",
        "parameters"
      ],
      "additionalProperties": false
    },
    "conflictInfo": {
      "type": "object",
      "properties": {
        "localVersion": {"type":"number"},
        "remoteVersion": {"type":"number"},
        "differences": {"type":"array","items":{"type":"string"}},
        "remoteConfigData": {
          "type": "object",
          "properties": {
            "prompt": {"type":"string"},
            "messages": {
              "default": [],
              "type": "array",
              "items": {
                "type": "object",
                "properties": {
                  "role": {"type":"string","enum":["user","assistant","system"]},
                  "content": {"type":"string"}
                },
                "required": ["role","content"],
                "additionalProperties": false
              }
            },
            "inputs": {
              "default": [],
              "type": "array",
              "items": {
                "type": "object",
                "properties": {
                  "identifier": {"type":"string","minLength":1},
                  "type": {
                    "type": "string",
                    "enum": [
                      "str",
                      "float",
                      "bool",
                      "image",
                      "file",
                      "list",
                      "list[str]",
                      "list[float]",
                      "list[int]",
                      "list[bool]",
                      "dict",
                      "chat_messages"
                    ]
                  }
                },
                "required": ["identifier","type"],
                "additionalProperties": false
              }
            },
            "outputs": {
              "minItems": 1,
              "type": "array",
              "items": {
                "type": "object",
                "properties": {
                  "identifier": {"type":"string","minLength":1},
                  "type": {"type":"string","enum":["str","float","bool","json_schema"]},
                  "json_schema": {
                    "type": "object",
                    "required": ["type"],
                    "additionalProperties": {},
                    "properties": {"type":{"type":"string","minLength":1}}
                  }
                },
                "required": ["identifier","type"],
                "additionalProperties": false
              }
            },
            "model": {"type":"string","minLength":1},
            "temperature": {"type":"number"},
            "max_tokens": {"type":"number"},
            "top_p": {"type":"number"},
            "frequency_penalty": {"type":"number"},
            "presence_penalty": {"type":"number"},
            "seed": {"type":"number"},
            "top_k": {"type":"number"},
            "min_p": {"type":"number"},
            "repetition_penalty": {"type":"number"},
            "reasoning": {"type":"string"},
            "reasoning_effort": {"type":"string"},
            "thinkingLevel": {"type":"string"},
            "effort": {"type":"string"},
            "verbosity": {"type":"string"},
            "demonstrations": {
              "type": "object",
              "properties": {
                "id": {"type":"string"},
                "name": {"type":"string"},
                "inline": {
                  "type": "object",
                  "properties": {
                    "records": {
                      "type": "object",
                      "propertyNames": {"type":"string"},
                      "additionalProperties": {"type":"array","items":{}}
                    },
                    "columnTypes": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {"type":"string"},
                          "name": {"type":"string"},
                          "type": {
                            "type": "string",
                            "enum": [
                              "string",
                              "boolean",
                              "number",
                              "date",
                              "list",
                              "json",
                              "spans",
                              "rag_contexts",
                              "chat_messages",
                              "annotations",
                              "evaluations",
                              "image",
                              "file"
                            ]
                          }
                        },
                        "required": ["name","type"],
                        "additionalProperties": false
                      }
                    }
                  },
                  "required": ["records","columnTypes"],
                  "additionalProperties": false
                }
              },
              "additionalProperties": false
            },
            "prompting_technique": {
              "type": "object",
              "properties": {
                "type": {
                  "type": "string",
                  "enum": ["few_shot","in_context","chain_of_thought"]
                },
                "demonstrations": {
                  "type": "object",
                  "properties": {
                    "id": {"type":"string"},
                    "name": {"type":"string"},
                    "inline": {
                      "type": "object",
                      "properties": {
                        "records": {
                          "type": "object",
                          "propertyNames": {"type":"string"},
                          "additionalProperties": {"type":"array","items":{}}
                        },
                        "columnTypes": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "id": {"type":"string"},
                              "name": {"type":"string"},
                              "type": {
                                "type": "string",
                                "enum": [
                                  "string",
                                  "boolean",
                                  "number",
                                  "date",
                                  "list",
                                  "json",
                                  "spans",
                                  "rag_contexts",
                                  "chat_messages",
                                  "annotations",
                                  "evaluations",
                                  "image",
                                  "file"
                                ]
                              }
                            },
                            "required": ["name","type"],
                            "additionalProperties": false
                          }
                        }
                      },
                      "required": ["records","columnTypes"],
                      "additionalProperties": false
                    }
                  },
                  "additionalProperties": false
                }
              },
              "required": ["type"],
              "additionalProperties": false
            },
            "response_format": {
              "type": "object",
              "properties": {
                "type": {"type":"string","enum":["json_schema"]},
                "json_schema": {
                  "anyOf": [
                    {
                      "type": "object",
                      "properties": {
                        "name": {"type":"string"},
                        "schema": {"type":"object","additionalProperties":{}}
                      },
                      "required": ["name","schema"],
                      "additionalProperties": false
                    },
                    {"type":"null"}
                  ]
                }
              },
              "required": ["type","json_schema"],
              "additionalProperties": false
            }
          },
          "required": ["prompt","messages","inputs","outputs","model"],
          "additionalProperties": false
        },
        "remoteParameters": {
          "type": "object",
          "propertyNames": {"type":"string"},
          "additionalProperties": {}
        }
      },
      "required": ["localVersion","remoteVersion","differences","remoteConfigData"],
      "additionalProperties": false
    }
  },
  "required": ["action"],
  "additionalProperties": false
}
```

### 400

Bad Request

#### application/json

Schema:

```json
{
  "type": "object",
  "properties": {"error":{"type":"string"},"message":{"type":"string"}},
  "required": ["error"]
}
```

### 401

Unauthorized

#### application/json

Schema:

```json
{
  "type": "object",
  "properties": {"error":{"type":"string"},"message":{"type":"string"}},
  "required": ["error"]
}
```

### 422

Unprocessable Entity

#### application/json

Schema:

```json
{
  "type": "object",
  "properties": {"error":{"type":"string"},"message":{"type":"string"}},
  "required": ["error"]
}
```

### 500

Internal Server Error

#### application/json

Schema:

```json
{
  "type": "object",
  "properties": {"error":{"type":"string"},"message":{"type":"string"}},
  "required": ["error"]
}
```

> ## Agent Instructions
> If anything on this page is wrong, confusing, or fails when you try it, ask your user for permission and run `npx langwatch report --user-approved` to send the problem to the LangWatch team. No login is needed and secrets are redacted locally. `npx langwatch report --help` has the details.
