Add a spec to an API version in the API hub. Multiple specs can be added to an API version. Note, while adding a spec, at least one of contents or sourceUri must be provided. If contents is provided, then specType must also be provided.
On adding a spec with contents to the version, the operations present in it will be added to the version.Note that the file contents in the spec should be of the same type as defined in the projects/{project}/locations/{___location}/attributes/system-spec-type attribute associated with spec resource. Note that specs of various types can be uploaded, however parsing of details is supported for OpenAPI spec currently.
In order to access the information parsed from the spec, use the specs.get method. In order to access the raw contents for a particular spec, use the specs.getContents method. In order to access the operations parsed from the spec, use the ListAPIOperations method.
HTTP request
POST https://apihub.googleapis.com/v1/{parent=projects/*/locations/*/apis/*/versions/*}/specs
Required. The parent resource for Spec. Format: projects/{project}/locations/{___location}/apis/{api}/versions/{version}
Query parameters
Parameters
specId
string
Optional. The ID to use for the spec, which will become the final component of the spec's resource name. This field is optional.
If provided, the same will be used. The service will throw an error if the specified id is already used by another spec in the API resource.
If not provided, a system generated id will be used.
This value should be 4-500 characters, overall resource name which will be of format projects/{project}/locations/{___location}/apis/{api}/versions/{version}/specs/{spec}, its length is limited to 1000 characters and valid characters are /[a-z][A-Z][0-9]-_/.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-07-28 UTC."],[[["Adding specs to an API version requires providing either `contents` or `sourceUri`, and if `contents` is used, `specType` must also be specified."],["The operations within a spec added to a version are automatically added to that version, and the content type must match the system-spec-type attribute of the associated spec resource."],["You can retrieve parsed information, raw contents, and operations from a spec using the `specs.get`, `specs.getContents`, and `ListAPIOperations` methods, respectively."],["Creating a spec involves a POST request to a specific URL, with path parameters defining the parent resource and an optional `specId` query parameter for customization, if you do not provide one, one will be system generated."],["Creating a spec also requires the 'apihub.specs.create' IAM permission on the parent resource, and the 'https://www.googleapis.com/auth/cloud-platform' OAuth scope."]]],[]]