---
title: "POST /v1/projects/{projectsId}/locations/{locationsId}/generatedSpecApis/{generatedSpecApisId}:generateSpec"
method: POST
path: "/v1/projects/{projectsId}/locations/{locationsId}/generatedSpecApis/{generatedSpecApisId}:generateSpec"
tags: ["projects"]
---

# POST /v1/projects/{projectsId}/locations/{locationsId}/generatedSpecApis/{generatedSpecApisId}:generateSpec

`POST /v1/projects/{projectsId}/locations/{locationsId}/generatedSpecApis/{generatedSpecApisId}:generateSpec`

## Request

- Base URL: `https://apihub.googleapis.com`
- URL: `https://apihub.googleapis.com/v1/projects/{projectsId}/locations/{locationsId}/generatedSpecApis/{generatedSpecApisId}:generateSpec`
- Auth: one of:
  - OAuth 2 and OAuth 2
    - Implicit: `https://accounts.google.com/o/oauth2/auth`
    - Scopes: `https://www.googleapis.com/auth/apihub.readonly`
    - Authorization code: `https://accounts.google.com/o/oauth2/auth`
    - Token URL: `https://accounts.google.com/o/oauth2/token` scopes: `https://www.googleapis.com/auth/apihub.readonly`
  - OAuth 2 and OAuth 2
    - Implicit: `https://accounts.google.com/o/oauth2/auth`
    - Scopes: `https://www.googleapis.com/auth/apihub.readwrite`
    - Authorization code: `https://accounts.google.com/o/oauth2/auth`
    - Token URL: `https://accounts.google.com/o/oauth2/token` scopes: `https://www.googleapis.com/auth/apihub.readwrite`
  - OAuth 2 and OAuth 2
    - Implicit: `https://accounts.google.com/o/oauth2/auth`
    - Scopes: `https://www.googleapis.com/auth/cloud-platform`
    - Authorization code: `https://accounts.google.com/o/oauth2/auth`
    - Token URL: `https://accounts.google.com/o/oauth2/token` scopes: `https://www.googleapis.com/auth/cloud-platform`
- TypeScript: <https://skmtc.dev/google/apis/apihub/docs/v1/projects/:projectsId/locations/:locationsId/generatedSpecApis/:generatedSpecApisId:generateSpec/post.ts> (a function with typed inputs; its response is checked against the schema)

Merges the per-day stored specs across the requested window and returns the merged OpenAPI document. Preview: this method is in Public Preview. Behavior and the API surface may change until the Spec Generation feature reaches General Availability.

## Path parameters

- `projectsId` string, required
- `locationsId` string, required
- `generatedSpecApisId` string, required

## Request body

- GoogleCloudApihubV1GenerateSpecRequest: Request for GenerateSpec.
  - `observationWindow` GoogleTypeInterval: Represents a time interval, encoded as a Timestamp start (inclusive) and a Timestamp end (exclusive). The start must be less than or equal to the end. When the start equals the end, the interval is empty (matches no time). When both start and end are unspecified, the interval matches any time.
    - `endTime` string, google-datetime: Optional. Exclusive end of the interval. If specified, a Timestamp matching this interval will have to be before the end.
    - `startTime` string, google-datetime: Optional. Inclusive start of the interval. If specified, a Timestamp matching this interval will have to be the same or after the start.

## Response `200`

Successful response

- GoogleCloudApihubV1GenerateSpecResponse: Response for GenerateSpec.
  - `generatedSpec` GoogleCloudApihubV1SpecContents: The spec contents.
    - `contents` string, byte: Required. The contents of the spec. The contents should be base64 encoded while calling the OnePlatform APIs like CreateSpec, UpdateSpec and CollectApiData.
    - `mimeType` string: Required. The mime type of the content for example application/json, application/yaml, application/wsdl etc.

## Changes

- **2026-11-08** `09b6c7d2247b`: 1 info
  - endpoint added

[Operation history](https://skmtc.dev/google/apis/apihub/changes/v1/projects/:projectsId/locations/:locationsId/generatedSpecApis/:generatedSpecApisId:generateSpec/post.md)

---

[API](https://skmtc.dev/google/apis/apihub.md) - [All operations](https://skmtc.dev/google/apis/apihub/llms.txt) - [OpenAPI document](https://skmtc.dev/google/apis/apihub/revisions/09b6c7d2247b?raw)
