{
  "openapi": "3.0.3",
  "info": {
    "title": "Surplus Salvage Intake API",
    "version": "1.0.0",
    "description": "Server-to-server private draft intake. Get a test or live connection key at /salvage/integrations. Each connection belongs to one Surplus account; only that account can review its items. Identical externalId + payload retries are idempotent indefinitely while the submission is retained. Rotating a key keeps the same connection identity. Files remain with the sender. No automatic publication, buyer emails, or media analysis."
  },
  "servers": [
    {
      "url": "https://surplus.com"
    }
  ],
  "security": [
    {
      "integrationKey": []
    }
  ],
  "paths": {
    "/api/v1/salvage/submissions": {
      "post": {
        "operationId": "sendToSurplus",
        "summary": "Create a private salvage draft",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SubmissionInput"
              },
              "example": {
                "externalId": "claim-1048/item-1",
                "title": "Standby diesel generator",
                "location": "Columbia, MO",
                "condition": "Not confirmed",
                "media": []
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Private draft created",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "submission",
                    "replayed"
                  ],
                  "properties": {
                    "submission": {
                      "$ref": "#/components/schemas/Submission"
                    },
                    "replayed": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "200": {
            "description": "Identical retry; existing submission returned",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "submission",
                    "replayed"
                  ],
                  "properties": {
                    "submission": {
                      "$ref": "#/components/schemas/Submission"
                    },
                    "replayed": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid JSON",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Missing, revoked, expired or invalid API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "externalId already used with a different payload",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "Body exceeds 64 KB",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "415": {
            "description": "Content-Type must be application/json",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "Invalid fields",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "60 requests/minute exceeded; retry after 60 seconds",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer"
                },
                "description": "Seconds to wait"
              }
            }
          },
          "503": {
            "description": "Temporarily unavailable; retry same externalId after 30 seconds",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer"
                },
                "description": "Seconds to wait"
              }
            }
          }
        }
      }
    },
    "/api/v1/salvage/submissions/{id}": {
      "get": {
        "operationId": "getSalvageSubmission",
        "summary": "Read this connection\u2019s submission",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Submission found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "submission"
                  ],
                  "properties": {
                    "submission": {
                      "$ref": "#/components/schemas/Submission"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, revoked, expired or invalid API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Not found, including another connection\u2019s item",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "60 requests/minute exceeded; retry after 60 seconds",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer"
                },
                "description": "Seconds to wait"
              }
            }
          },
          "503": {
            "description": "Temporarily unavailable; retry same externalId after 30 seconds",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer"
                },
                "description": "Seconds to wait"
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "integrationKey": {
        "type": "http",
        "scheme": "bearer",
        "description": "Server-side Surplus integration key. Never place in client-side code. Keys expire after one year."
      }
    },
    "schemas": {
      "SubmissionInput": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "externalId",
          "title",
          "location"
        ],
        "properties": {
          "externalId": {
            "type": "string",
            "minLength": 1,
            "maxLength": 160,
            "pattern": "^[A-Za-z0-9][A-Za-z0-9_.:/-]*$",
            "description": "Stable unique item reference within this connection. Identical retries return the existing submission; changed payload returns 409."
          },
          "title": {
            "type": "string",
            "minLength": 3,
            "maxLength": 140
          },
          "location": {
            "type": "string",
            "minLength": 3,
            "maxLength": 160
          },
          "claim": {
            "type": "string",
            "maxLength": 80,
            "default": ""
          },
          "notes": {
            "type": "string",
            "maxLength": 8000,
            "default": ""
          },
          "condition": {
            "type": "string",
            "minLength": 1,
            "maxLength": 2000,
            "default": "Not confirmed"
          },
          "loading": {
            "type": "string",
            "maxLength": 2000,
            "default": "Not confirmed"
          },
          "available": {
            "type": "string",
            "format": "date"
          },
          "deadline": {
            "type": "string",
            "format": "date",
            "description": "On or after available, if both supplied."
          },
          "media": {
            "type": "array",
            "maxItems": 30,
            "default": [],
            "items": {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "kind",
                "url"
              ],
              "properties": {
                "kind": {
                  "type": "string",
                  "enum": [
                    "photo",
                    "video",
                    "document"
                  ]
                },
                "url": {
                  "type": "string",
                  "format": "uri",
                  "maxLength": 2048,
                  "description": "HTTPS on a public hostname, port 443 only, no embedded credentials or fragment. Stored as a link; not fetched."
                },
                "name": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 160
                }
              }
            }
          }
        }
      },
      "Submission": {
        "type": "object",
        "required": [
          "id",
          "integrationId",
          "integrationName",
          "mode",
          "status",
          "data",
          "version",
          "createdAt",
          "updatedAt",
          "reviewUrl"
        ],
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "integrationId": {
            "type": "string",
            "format": "uuid"
          },
          "integrationName": {
            "type": "string"
          },
          "mode": {
            "type": "string",
            "enum": [
              "test",
              "live"
            ]
          },
          "status": {
            "type": "string",
            "enum": [
              "draft",
              "reviewed",
              "archived"
            ]
          },
          "data": {
            "$ref": "#/components/schemas/SubmissionInput"
          },
          "version": {
            "type": "integer",
            "minimum": 1
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "updatedAt": {
            "type": "string",
            "format": "date-time"
          },
          "reviewUrl": {
            "type": "string",
            "format": "uri"
          }
        }
      },
      "Error": {
        "type": "object",
        "required": [
          "error"
        ],
        "properties": {
          "error": {
            "type": "object",
            "required": [
              "code",
              "message"
            ],
            "properties": {
              "code": {
                "type": "string"
              },
              "message": {
                "type": "string"
              }
            }
          }
        }
      }
    }
  }
}
