{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/typeship-dev/json-schema/typeship-dev-target-create-request-schema.json",
  "title": "TargetCreateRequest",
  "x-generated": "2026-11-27",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/typeship-dev-openapi.json#/components/schemas/TargetCreateRequest",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "project_id",
    "name",
    "type"
  ],
  "properties": {
    "project_id": {
      "$ref": "#/$defs/ProjectId"
    },
    "name": {
      "type": "string",
      "minLength": 1,
      "maxLength": 80
    },
    "type": {
      "$ref": "#/$defs/GeneratorKind"
    },
    "status": {
      "type": "string",
      "enum": [
        "active",
        "disabled"
      ],
      "default": "active"
    },
    "release_channel": {
      "type": "string",
      "enum": [
        "stable",
        "prerelease"
      ],
      "default": "stable"
    },
    "checks": {
      "$ref": "#/$defs/TargetChecks"
    },
    "config": {
      "oneOf": [
        {
          "$ref": "#/$defs/TargetConfig"
        },
        {
          "type": "null"
        }
      ],
      "description": "Target-specific overrides merged over Project.config. GraphQL settings are rejected here and belong to the Spec."
    },
    "deliveries": {
      "type": "array",
      "maxItems": 2,
      "items": {
        "$ref": "#/$defs/DeliveryInput"
      }
    }
  },
  "$defs": {
    "DeliveryInput": {
      "oneOf": [
        {
          "$ref": "#/$defs/RepositoryDeliveryInput"
        },
        {
          "$ref": "#/$defs/HostedMcpDeliveryInput"
        }
      ]
    },
    "GeneratorKind": {
      "type": "string",
      "enum": [
        "cli",
        "mcp",
        "typescript_sdk",
        "python_sdk",
        "go_sdk"
      ],
      "description": "Package type selected by a Target. Several Targets may use the same type. The CLI is a self-contained command-line package and requires no SDK Target."
    },
    "HostedMcpDeliveryInput": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "type"
      ],
      "properties": {
        "type": {
          "type": "string",
          "const": "hosted_mcp"
        }
      }
    },
    "McpBehavior": {
      "type": "object",
      "additionalProperties": false,
      "description": "How generated MCP servers and the Typeship-hosted endpoint behave. Part of Config.",
      "properties": {
        "registry_name": {
          "type": [
            "string",
            "null"
          ],
          "description": "Stable official MCP registry name, independent of the server runtime."
        },
        "access": {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "issuer",
            "resource"
          ],
          "description": "Authorization for callers connecting to a generated MCP server deployed over HTTP. The hosting application resolves upstream API credentials separately at runtime. This setting does not apply to the Typeship-hosted endpoint.",
          "properties": {
            "issuer": {
              "type": "string",
              "format": "uri",
              "description": "Exact issuer allowed to sign MCP connection tokens."
            },
            "resource": {
              "type": "string",
              "format": "uri",
              "description": "Canonical public URL of the self-hosted MCP endpoint that connection tokens must target."
            },
            "jwks_url": {
              "type": "string",
              "format": "uri",
              "description": "Public signing-key endpoint. Omit to discover it from the issuer."
            },
            "scopes": {
              "type": "array",
              "maxItems": 20,
              "items": {
                "type": "string"
              },
              "description": "Minimum scopes required to connect to the self-hosted MCP server."
            }
          }
        },
        "tool_mode": {
          "type": "string",
          "enum": [
            "auto",
            "operations",
            "meta"
          ],
          "description": "MCP tool shape. meta collapses per-operation tools into search_docs, read_docs, and execute so large APIs don't flood an agent's context window. Auto considers the serialized tool schemas, switching near 10k tokens or above 100 operations."
        },
        "instructions": {
          "type": [
            "string",
            "null"
          ],
          "maxLength": 2000,
          "description": "Guidance appended to the MCP server's instructions, which agents read once when they connect (server/discover): what to call first, conventions the spec does not state, what not to do. Carried by the package's server and the hosted endpoint alike."
        },
        "tool_descriptions": {
          "type": "object",
          "additionalProperties": {
            "type": "string",
            "maxLength": 600
          },
          "maxProperties": 200,
          "description": "Hand-written MCP tool descriptions keyed by operationId or \"METHOD /path\". Each replaces the text typeship derives for that operation (summary, first sentence, method and path, deprecation and auth notes). For flows the spec cannot describe, such as a multi-step upload. Keys that match no operation are reported as generation warnings."
        },
        "reference_resolvers": {
          "type": "object",
          "maxProperties": 200,
          "description": "Exact name-or-ID resolver overrides keyed first by the target operationId or \"METHOD /path\", then by its wire argument name. A resolver names one read collection operation plus 1-4 item fields to match case-insensitively; false opts that argument out of strict inference.",
          "additionalProperties": {
            "type": "object",
            "maxProperties": 20,
            "additionalProperties": {
              "oneOf": [
                {
                  "type": "boolean",
                  "enum": [
                    false
                  ]
                },
                {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "via",
                    "match"
                  ],
                  "properties": {
                    "via": {
                      "type": "string",
                      "maxLength": 200,
                      "description": "OperationId, \"METHOD /path\", MCP tool name, or dotted resource.method of the list operation."
                    },
                    "match": {
                      "type": "array",
                      "minItems": 1,
                      "maxItems": 4,
                      "uniqueItems": true,
                      "items": {
                        "type": "string",
                        "maxLength": 100
                      },
                      "description": "Item fields compared exactly and case-insensitively, such as name, slug, key, or email."
                    },
                    "id": {
                      "type": "string",
                      "maxLength": 100,
                      "description": "Item field substituted into the requested argument. Defaults to id."
                    }
                  }
                }
              ]
            }
          }
        }
      }
    },
    "PackageBehavior": {
      "type": "object",
      "additionalProperties": false,
      "description": "Published-package metadata the API spec does not own. Repository is derived from each destination.",
      "properties": {
        "title": {
          "type": [
            "string",
            "null"
          ],
          "maxLength": 100,
          "description": "The API's name as generated READMEs, AGENTS.md, package descriptions, and help text show it, such as \"Parcel\" for a Spec titled \"Parcel - Public API\". Display only: package, client, and command names still come from the Spec. Defaults to the Spec title with common noise removed (\"Parcel - API\" shows as Parcel)."
        },
        "homepage": {
          "type": [
            "string",
            "null"
          ],
          "description": "Homepage written into registry metadata."
        },
        "license": {
          "type": [
            "string",
            "null"
          ],
          "maxLength": 200,
          "description": "SPDX identifier written into registry metadata. Defaults to info.license."
        },
        "license_text": {
          "type": [
            "string",
            "null"
          ],
          "maxLength": 100000,
          "description": "Exact LICENSE file contents. Supply this for licences the engine does not build in; MIT is built in when copyright is also set."
        },
        "copyright": {
          "type": [
            "string",
            "null"
          ],
          "maxLength": 200,
          "description": "Copyright line used in generated license files."
        },
        "go_package_name": {
          "type": [
            "string",
            "null"
          ],
          "description": "Go identifier when the destination repository name is unsuitable."
        }
      }
    },
    "PaginationRule": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "items_field"
      ],
      "properties": {
        "style": {
          "type": "string",
          "enum": [
            "cursor",
            "cursor_from_last_id",
            "page",
            "offset"
          ],
          "default": "cursor"
        },
        "items_field": {
          "type": "string",
          "description": "Response field holding the item array."
        },
        "cursor_param": {
          "type": "string"
        },
        "next_cursor_field": {
          "type": "string"
        },
        "has_more_field": {
          "type": "string"
        },
        "id_field": {
          "type": "string"
        },
        "page_param": {
          "type": "string"
        },
        "offset_param": {
          "type": "string"
        },
        "limit_param": {
          "type": "string"
        }
      }
    },
    "ProjectId": {
      "type": "string",
      "pattern": "^prj_[a-z0-9]{16}$",
      "description": "Unique identifier for a project."
    },
    "ReadmeBehavior": {
      "type": "object",
      "additionalProperties": false,
      "description": "Generated README behavior. Part of Config.",
      "properties": {
        "quickstart_operation": {
          "type": [
            "string",
            "null"
          ],
          "maxLength": 500,
          "description": "operationId or \"METHOD /path\" to feature as the README's first API call. It must be present in the generated package and callable with no required input beyond path placeholders. Missing or unsuitable choices produce a warning and use the automatic example."
        }
      }
    },
    "RepositoryDeliveryInput": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "type",
        "repository"
      ],
      "properties": {
        "type": {
          "type": "string",
          "const": "repository"
        },
        "repository": {
          "$ref": "#/$defs/RepositoryDeliverySettingsInput"
        }
      }
    },
    "RepositoryDeliverySettingsInput": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "provider",
        "identifier"
      ],
      "properties": {
        "provider": {
          "$ref": "#/$defs/RepositoryProvider"
        },
        "identifier": {
          "$ref": "#/$defs/RepositoryIdentifier"
        },
        "directory": {
          "type": [
            "string",
            "null"
          ]
        },
        "package_name": {
          "type": [
            "string",
            "null"
          ],
          "description": "npm or Python registry identity where applicable."
        },
        "module_path": {
          "type": [
            "string",
            "null"
          ],
          "description": "Go module identity for the Go SDK or CLI Target where applicable."
        },
        "publish_on_merge": {
          "type": "boolean",
          "default": false,
          "description": "Commit repository-owned registry automation and report publication after the Draft merges."
        }
      }
    },
    "RepositoryIdentifier": {
      "type": "string",
      "maxLength": 512,
      "description": "Provider-native repository identity, opaque outside its adapter."
    },
    "RepositoryProvider": {
      "type": "string",
      "enum": [
        "github"
      ],
      "description": "GitHub is the only launch provider; the field is stable for future adapters."
    },
    "RetryTuning": {
      "type": "object",
      "additionalProperties": false,
      "description": "Retry behavior. Top-level fields adjust every operation; operations maps operationId or \"METHOD /path\" keys to per-operation overrides.",
      "properties": {
        "max_retries": {
          "type": "integer",
          "minimum": 0,
          "maximum": 10
        },
        "statuses": {
          "type": "array",
          "items": {
            "type": "integer"
          },
          "maxItems": 20,
          "description": "Replaces the default retryable set (408, 429, 500, 502, 503, 504)."
        },
        "initial_delay_ms": {
          "type": "integer",
          "minimum": 1
        },
        "max_delay_ms": {
          "type": "integer",
          "minimum": 1
        },
        "retry_non_idempotent": {
          "type": "boolean",
          "description": "Also retry non-idempotent methods (POST/PATCH)."
        },
        "disabled": {
          "type": "boolean",
          "description": "Shorthand for max_retries 0."
        },
        "operations": {
          "type": "object",
          "maxProperties": 100,
          "additionalProperties": {
            "$ref": "#/$defs/RetryTuning"
          }
        }
      }
    },
    "TargetAuthenticationConfig": {
      "type": "object",
      "additionalProperties": false,
      "description": "Selects a Project OAuth application for one Target. OAuth server metadata, applications, and identity policy remain Project-owned.",
      "properties": {
        "oauth_application": {
          "type": [
            "string",
            "null"
          ],
          "maxLength": 64,
          "pattern": "^[a-z][a-z0-9_-]{0,63}$",
          "description": "Project OAuth application to use. Omit to inherit the Project default."
        },
        "environments": {
          "type": [
            "object",
            "null"
          ],
          "maxProperties": 20,
          "propertyNames": {
            "pattern": "^[A-Za-z_$][A-Za-z0-9_$]{0,127}$"
          },
          "additionalProperties": {
            "$ref": "#/$defs/TargetAuthenticationEnvironment"
          },
          "description": "Project OAuth application selections keyed by API environment."
        }
      }
    },
    "TargetAuthenticationEnvironment": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "oauth_application": {
          "type": [
            "string",
            "null"
          ],
          "maxLength": 64,
          "pattern": "^[a-z][a-z0-9_-]{0,63}$"
        }
      }
    },
    "TargetChecks": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "generated": {
          "type": "array",
          "uniqueItems": true,
          "default": [
            "build",
            "package",
            "public_entrypoint"
          ],
          "items": {
            "type": "string",
            "enum": [
              "build",
              "package",
              "public_entrypoint"
            ]
          }
        },
        "repository_required": {
          "type": "array",
          "maxItems": 50,
          "uniqueItems": true,
          "items": {
            "type": "string",
            "minLength": 1,
            "maxLength": 120
          }
        },
        "customer": {
          "type": "array",
          "maxItems": 20,
          "items": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "name",
              "command"
            ],
            "properties": {
              "name": {
                "type": "string",
                "minLength": 1,
                "maxLength": 120
              },
              "command": {
                "type": "string",
                "minLength": 1,
                "maxLength": 2000
              }
            }
          }
        }
      },
      "description": "Required checks run against the code in the Draft. Generated checks and customer commands share one reproducible workflow; repository_required names existing repository checks. Supplying checks replaces all settings. Omitted generated restores build, package, and public_entrypoint; omitted repository_required and customer restore empty lists. An empty object restores these defaults. An empty array clears the corresponding list."
    },
    "TargetCliBehavior": {
      "type": "object",
      "additionalProperties": false,
      "description": "How the generated CLI behaves. Part of Config.",
      "properties": {
        "command_name": {
          "type": [
            "string",
            "null"
          ],
          "description": "Command users run, independent of how the CLI is distributed."
        },
        "changelog_url": {
          "type": [
            "string",
            "null"
          ],
          "description": "Public HTTP(S) URL read by the optional changelog command in generated CLIs. Supports UTF-8 Markdown, plain text, and static HTML; embedded credentials are not allowed. Omit or clear to disable, then regenerate."
        },
        "support_url": {
          "type": [
            "string",
            "null"
          ],
          "description": "Where the generated CLI's feedback command sends users. GitHub issues/new URLs get a prefilled title and environment details."
        },
        "mcp_url": {
          "type": [
            "string",
            "null"
          ],
          "description": "Fallback MCP endpoint used by the generated CLI when the Project has no Typeship-hosted MCP endpoint. A hosted endpoint takes precedence over this URL."
        },
        "skills_repo": {
          "type": [
            "string",
            "null"
          ],
          "description": "Repository in owner/name format that the generated CLI's init command offers for skill installation."
        },
        "relay": {
          "type": "boolean",
          "description": "Enable webhook relay sessions for this CLI Target. Requires Pro. Turning it off prevents new sessions."
        },
        "unit_tests": {
          "type": "boolean",
          "description": "Also generate unit tests for the helper code a CLI shares, such as raw API path checks, saved credentials, and MCP client configuration. Applies to cli Targets. Off by default; tests for the generated commands are always included."
        }
      }
    },
    "TargetConfig": {
      "type": "object",
      "additionalProperties": false,
      "description": "Target-specific generation and delivery overrides. Authentication may only select a Project-owned OAuth application. OAuth server metadata, applications, and identity policy remain Project-owned. Self-hosted MCP access may be overridden for a Target-specific deployment.",
      "properties": {
        "globals": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "maxItems": 20,
          "description": "Wire names of query/header parameters that become settable once on the generated client and auto-apply to every operation that accepts them; per-call values win. Names that match nothing are reported as generation warnings."
        },
        "include": {
          "type": "array",
          "maxItems": 100,
          "items": {
            "type": "string",
            "minLength": 1,
            "maxLength": 500
          },
          "description": "Generate only matching operations: tag names, or path globs such as `/zones/**` (`*` is one path segment, `**` any number), optionally after an HTTP method (`DELETE /zones/*`). Applied before the Spec size limit, with components nothing references any more removed, so a one-shot run can generate part of a Spec up to 64 MB. Selectors that match nothing are reported as generation warnings."
        },
        "exclude": {
          "type": "array",
          "maxItems": 100,
          "items": {
            "type": "string",
            "minLength": 1,
            "maxLength": 500
          },
          "description": "Leave out matching operations (tag names or path globs, as for `include`). Wins over `include`."
        },
        "retries": {
          "$ref": "#/$defs/RetryTuning"
        },
        "pagination": {
          "type": "object",
          "maxProperties": 100,
          "additionalProperties": {
            "oneOf": [
              {
                "$ref": "#/$defs/PaginationRule"
              },
              {
                "type": "boolean",
                "description": "false disables pagination detection for the operation."
              }
            ]
          },
          "description": "Per-operation pagination control, keyed by operationId or \"METHOD /path\". Unmatched keys are reported as generation warnings."
        },
        "auth": {
          "$ref": "#/$defs/TargetAuthenticationConfig"
        },
        "cli": {
          "$ref": "#/$defs/TargetCliBehavior"
        },
        "mcp": {
          "$ref": "#/$defs/McpBehavior"
        },
        "readme": {
          "$ref": "#/$defs/ReadmeBehavior"
        },
        "package": {
          "$ref": "#/$defs/PackageBehavior"
        },
        "docs_url": {
          "type": [
            "string",
            "null"
          ],
          "format": "uri",
          "description": "The API's documentation site. Read through its llms.txt by the generated CLI's docs command, the MCP server's docs tools, and the package's AGENTS.md. Defaults to the Spec's externalDocs URL."
        },
        "docs_index_url": {
          "type": [
            "string",
            "null"
          ],
          "format": "uri",
          "description": "Exact llms.txt URL when the documentation site does not publish it at docs_url + /llms.txt."
        }
      }
    }
  }
}