---
title: "POST /v1/{+parent}/specs"
method: POST
path: "/v1/{+parent}/specs"
tags: ["projects"]
---

# POST /v1/{+parent}/specs

`POST /v1/{+parent}/specs`

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 `source_uri` must be provided. If `contents` is provided, then `spec_type` 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 GetSpec method. In order to access the raw contents for a particular spec, use the GetSpecContents method. In order to access the operations parsed from the spec, use the ListAPIOperations method.

## Path parameters

- `parent` string, required

## Query parameters

- `specId` string

## Request body

- GoogleCloudApihubV1Spec — Represents a spec associated with an API version in the API Hub. Note that specs of various types can be uploaded, however parsing of details is supported for OpenAPI spec currently.
  - `details` GoogleCloudApihubV1SpecDetails — SpecDetails contains the details parsed from supported spec types.
    - `openApiSpecDetails` GoogleCloudApihubV1OpenApiSpecDetails — OpenApiSpecDetails contains the details parsed from an OpenAPI spec in addition to the fields mentioned in SpecDetails.
      - `format` 'FORMAT_UNSPECIFIED' | 'OPEN_API_SPEC_2_0' | 'OPEN_API_SPEC_3_0' | 'OPEN_API_SPEC_3_1' — Output only. The format of the spec.
      - `version` string — Output only. The version in the spec. This maps to `info.version` in OpenAPI spec.
      - `owner` GoogleCloudApihubV1Owner — Owner details.
        - `displayName` string — Optional. The name of the owner.
        - `email` string — Required. The email of the owner.
    - `description` string — Output only. The description of the spec.
  - `sourceMetadata` GoogleCloudApihubV1SourceMetadata[] — Output only. The list of sources and metadata from the sources of the spec.
    - `originalResourceUpdateTime` string, google-datetime — Output only. The time at which the resource was last updated at the source.
    - `originalResourceId` string — Output only. The unique identifier of the resource at the source.
    - `originalResourceCreateTime` string, google-datetime — Output only. The time at which the resource was created at the source.
    - `pluginInstanceActionSource` GoogleCloudApihubV1PluginInstanceActionSource — PluginInstanceActionSource represents the plugin instance action source.
      - `actionId` string — Output only. The id of the plugin instance action.
      - `pluginInstance` string — Output only. The resource name of the source plugin instance. Format is `projects/{project}/locations/{location}/plugins/{plugin}/instances/{instance}`
    - `sourceType` 'SOURCE_TYPE_UNSPECIFIED' | 'PLUGIN' — Output only. The type of the source.
  - `updateTime` string, google-datetime — Output only. The time at which the spec was last updated.
  - `lintResponse` GoogleCloudApihubV1LintResponse — LintResponse contains the response from the linter.
    - `linter` 'LINTER_UNSPECIFIED' | 'SPECTRAL' | 'OTHER' — Required. Name of the linter used.
    - `state` 'LINT_STATE_UNSPECIFIED' | 'LINT_STATE_SUCCESS' | 'LINT_STATE_ERROR' — Required. Lint state represents success or failure for linting.
    - `source` string — Required. Name of the linting application.
    - `issues` GoogleCloudApihubV1Issue[] — Optional. Array of issues found in the analyzed document.
      - `path` string[] — Required. An array of strings indicating the location in the analyzed document where the rule was triggered.
      - `severity` 'SEVERITY_UNSPECIFIED' | 'SEVERITY_ERROR' | 'SEVERITY_WARNING' | 'SEVERITY_INFO' | 'SEVERITY_HINT' — Required. Severity level of the rule violation.
      - `code` string — Required. Rule code unique to each rule defined in linter.
      - `range` GoogleCloudApihubV1Range — Object describing where in the file the issue was found.
        - `start` GoogleCloudApihubV1Point — Point within the file (line and character).
          - `line` integer — Required. Line number (zero-indexed).
          - `character` integer — Required. Character position within the line (zero-indexed).
        - `end` GoogleCloudApihubV1Point — Point within the file (line and character).
          - `line` integer — Required. Line number (zero-indexed).
          - `character` integer — Required. Character position within the line (zero-indexed).
      - `message` string — Required. Human-readable message describing the issue found by the linter.
    - `summary` GoogleCloudApihubV1SummaryEntry[] — Optional. Summary of all issue types and counts for each severity level.
      - `severity` 'SEVERITY_UNSPECIFIED' | 'SEVERITY_ERROR' | 'SEVERITY_WARNING' | 'SEVERITY_INFO' | 'SEVERITY_HINT' — Required. Severity of the issue.
      - `count` integer — Required. Count of issues with the given severity.
    - `createTime` string, google-datetime — Required. Timestamp when the linting response was generated.
  - `createTime` string, google-datetime — Output only. The time at which the spec was created.
  - `additionalSpecContents` GoogleCloudApihubV1AdditionalSpecContent[] — Output only. The additional spec contents for the spec.
    - `specContents` GoogleCloudApihubV1SpecContents — The spec contents.
      - `mimeType` string — Required. The mime type of the content for example application/json, application/yaml, application/wsdl etc.
      - `contents` string, byte — Required. The contents of the spec.
    - `specContentType` 'SPEC_CONTENT_TYPE_UNSPECIFIED' | 'BOOSTED_SPEC_CONTENT' | 'GATEWAY_OPEN_API_SPEC' — Required. The type of the spec content.
    - `updateTime` string, google-datetime — Output only. The time at which the spec content was last updated.
    - `createTime` string, google-datetime — Output only. The time at which the spec content was created.
    - `labels` object — Optional. The labels of the spec content e.g. specboost addon version.
  - `sourceUri` string — Optional. The URI of the spec source in case file is uploaded from an external version control system.
  - `attributes` object — Optional. The list of user defined attributes associated with the spec. The key is the attribute name. It will be of the format: `projects/{project}/locations/{location}/attributes/{attribute}`. The value is the attribute values associated with the resource.
  - `name` string — Identifier. The name of the spec. Format: `projects/{project}/locations/{location}/apis/{api}/versions/{version}/specs/{spec}`
  - `parsingMode` 'PARSING_MODE_UNSPECIFIED' | 'RELAXED' | 'STRICT' — Optional. Input only. Enum specifying the parsing mode for OpenAPI Specification (OAS) parsing.
  - `displayName` string — Required. The display name of the spec. This can contain the file name of the spec.
  - `documentation` GoogleCloudApihubV1Documentation — Documentation details.
    - `externalUri` string — Optional. The uri of the externally hosted documentation.
  - `contents` GoogleCloudApihubV1SpecContents — The spec contents.
    - `mimeType` string — Required. The mime type of the content for example application/json, application/yaml, application/wsdl etc.
    - `contents` string, byte — Required. The contents of the spec.
  - `specType` GoogleCloudApihubV1AttributeValues — The attribute values associated with resource.
    - `stringValues` GoogleCloudApihubV1StringAttributeValues — The attribute values of data type string or JSON.
      - `values` string[] — Required. The attribute values in case attribute data type is string or JSON.
    - `uriValues` GoogleCloudApihubV1StringAttributeValues — The attribute values of data type string or JSON.
      - `values` string[] — Required. The attribute values in case attribute data type is string or JSON.
    - `enumValues` GoogleCloudApihubV1EnumAttributeValues — The attribute values of data type enum.
      - `values` GoogleCloudApihubV1AllowedValue[] — Required. The attribute values in case attribute data type is enum.
        - `id` string — Required. The ID of the allowed value. * If provided, the same will be used. The service will throw an error if the specified id is already used by another allowed value in the same attribute resource. * If not provided, a system generated id derived from the display name will be used. In this case, the service will handle conflict resolution by adding a system generated suffix in case of duplicates. This value should be 4-63 characters, and valid characters are /a-z-/.
        - `displayName` string — Required. The display name of the allowed value.
        - `description` string — Optional. The detailed description of the allowed value.
        - `immutable` boolean — Optional. When set to true, the allowed value cannot be updated or deleted by the user. It can only be true for System defined attributes.
    - `jsonValues` GoogleCloudApihubV1StringAttributeValues — The attribute values of data type string or JSON.
      - `values` string[] — Required. The attribute values in case attribute data type is string or JSON.
    - `attribute` string — Output only. The name of the attribute. Format: projects/{project}/locations/{location}/attributes/{attribute}

## Response `200`

Successful response

---

[API](https://skmtc.dev/google/apis/apihub.md) · [All operations](https://skmtc.dev/google/apis/apihub/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/google/apihub/revisions/19473c7df886/schema)
