> For clean Markdown content of this page, append .md to this URL. For the complete documentation index, see https://learning.postman.com/llms.txt. For full content including API reference and SDK examples, see https://learning.postman.com/llms-full.txt.

# Migrate API Builder API to Spec Hub

POST https://api.getpostman.com/apis/{apiId}/spec-migrations
Content-Type: application/json

Migrates an API Builder definition to a [Spec Hub](https://learning.postman.com/docs/design-apis/specifications/overview) specification. You can migrate the definition to an existing workspace, or create a new workspace to migrate the definition into. On success, this returns an HTTP `202 Created` response. You can use the GET `/apis/{apiId}/spec-migrations` endpoint to check the migration status.

**Note:**

- This returns an HTTP `200 OK` response if the given API ID isn't an API Builder definition.
- To migrate a Git-linked API Builder definition to Spec Hub, you must create a new workspace. Migration to an existing workspace isn't supported.


Reference: https://learning.postman.com/api-docs/api-reference/specs/migrate-api-to-spec-hub

## OpenAPI Specification

```yaml
openapi: 3.1.0
info:
  title: Postman API
  version: 1.0.0
paths:
  /apis/{apiId}/spec-migrations:
    post:
      operationId: migrateApiToSpecHub
      summary: Migrate API Builder API to Spec Hub
      description: >
        Migrates an API Builder definition to a [Spec
        Hub](https://learning.postman.com/docs/design-apis/specifications/overview)
        specification. You can migrate the definition to an existing workspace,
        or create a new workspace to migrate the definition into. On success,
        this returns an HTTP `202 Created` response. You can use the GET
        `/apis/{apiId}/spec-migrations` endpoint to check the migration status.


        **Note:**


        - This returns an HTTP `200 OK` response if the given API ID isn't an
        API Builder definition.

        - To migrate a Git-linked API Builder definition to Spec Hub, you must
        create a new workspace. Migration to an existing workspace isn't
        supported.
      tags:
        - specs
      parameters:
        - name: apiId
          in: path
          description: The API's ID.
          required: true
          schema:
            $ref: '#/components/schemas/apiId'
        - name: x-api-key
          in: header
          required: true
          schema:
            type: string
        - name: Accept
          in: header
          description: >-
            The `application/vnd.api.v10+json` request header required to use
            the endpoint.
          required: true
          schema:
            $ref: '#/components/schemas/v10Accept'
      responses:
        '200':
          description: Empty API Migration
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/migrateToSpecHubResponse'
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/MigrateApiToSpecHubRequestBadRequestError'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/commonErrorTypeTitleDetailStatusInstance'
        '403':
          description: Forbidden
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/MigrateApiToSpecHubRequestForbiddenError'
        '500':
          description: Internal Server Error
          content:
            application/json:
              schema:
                $ref: >-
                  #/components/schemas/MigrateApiToSpecHubRequestInternalServerError
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/migrateApiToSpecHub'
servers:
  - url: https://api.getpostman.com
    description: https://api.getpostman.com
  - url: https://api.eu.postman.com
    description: https://api.eu.postman.com
components:
  schemas:
    apiId:
      type: string
      title: apiId
    v10Accept:
      type: string
      enum:
        - application/vnd.api.v10+json
      title: v10Accept
    migrateApiToSpecHubExistingWorkspace:
      type: object
      properties:
        workspaceId:
          type: string
          description: The ID of an existing workspace to migrate the definition to.
      required:
        - workspaceId
      title: migrateApiToSpecHubExistingWorkspace
    MigrateApiToSpecHubNewWorkspaceWorkspaceInfo:
      type: object
      properties:
        name:
          type: string
          description: The name of the workspace to create and migrate the definition to.
      required:
        - name
      description: Information about the new workspace.
      title: MigrateApiToSpecHubNewWorkspaceWorkspaceInfo
    migrateApiToSpecHubNewWorkspace:
      type: object
      properties:
        workspaceInfo:
          $ref: '#/components/schemas/MigrateApiToSpecHubNewWorkspaceWorkspaceInfo'
          description: Information about the new workspace.
      required:
        - workspaceInfo
      title: migrateApiToSpecHubNewWorkspace
    MigrateGitConnectedApiToSpecHubWorkspaceInfo:
      type: object
      properties:
        name:
          type: string
          description: The name of the workspace to create and migrate the definition to.
      required:
        - name
      description: Information about the new workspace.
      title: MigrateGitConnectedApiToSpecHubWorkspaceInfo
    MigrateGitConnectedApiToSpecHubGitInfo:
      type: object
      properties:
        path:
          type: string
          description: >-
            The directory path in the remote mono-repo containing the API's
            collections and definitions. This property expects an absolute path
            and only contains alphanumeric characters, slashes, hyphens,
            underscores, and periods. It cannot contain  path traversal
            sequences (\..\).
      required:
        - path
      description: Information about the connected remote Git mono-repo.
      title: MigrateGitConnectedApiToSpecHubGitInfo
    migrateGitConnectedApiToSpecHub:
      type: object
      properties:
        workspaceInfo:
          $ref: '#/components/schemas/MigrateGitConnectedApiToSpecHubWorkspaceInfo'
          description: Information about the new workspace.
        gitInfo:
          $ref: '#/components/schemas/MigrateGitConnectedApiToSpecHubGitInfo'
          description: Information about the connected remote Git mono-repo.
      required:
        - workspaceInfo
        - gitInfo
      title: migrateGitConnectedApiToSpecHub
    migrateApiToSpecHub:
      oneOf:
        - $ref: '#/components/schemas/migrateApiToSpecHubExistingWorkspace'
        - $ref: '#/components/schemas/migrateApiToSpecHubNewWorkspace'
        - $ref: '#/components/schemas/migrateGitConnectedApiToSpecHub'
      title: migrateApiToSpecHub
    migrateToSpecHubResponse:
      type: object
      properties:
        message:
          type: string
          description: The operation's message.
        success:
          type: boolean
          description: If true, the migration succeeded.
      title: migrateToSpecHubResponse
    MigrateApiToSpecHub400ErrorTitleMessageError:
      type: object
      properties:
        title:
          type: string
          description: A short summary of the problem.
        message:
          type: string
          description: The error message.
      title: MigrateApiToSpecHub400ErrorTitleMessageError
    migrateApiToSpecHub400ErrorTitleMessage:
      type: object
      properties:
        error:
          $ref: '#/components/schemas/MigrateApiToSpecHub400ErrorTitleMessageError'
      title: migrateApiToSpecHub400ErrorTitleMessage
    MigrateApiToSpecHub400ErrorTitleMessageDetailsErrorDetails:
      type: object
      properties:
        workspaceId:
          type: string
          description: The workspace's ID.
      description: Information about the error.
      title: MigrateApiToSpecHub400ErrorTitleMessageDetailsErrorDetails
    MigrateApiToSpecHub400ErrorTitleMessageDetailsError:
      type: object
      properties:
        title:
          type: string
          description: A short summary of the problem.
        details:
          $ref: >-
            #/components/schemas/MigrateApiToSpecHub400ErrorTitleMessageDetailsErrorDetails
          description: Information about the error.
        message:
          type: string
          description: The error message.
      title: MigrateApiToSpecHub400ErrorTitleMessageDetailsError
    migrateApiToSpecHub400ErrorTitleMessageDetails:
      type: object
      properties:
        error:
          $ref: >-
            #/components/schemas/MigrateApiToSpecHub400ErrorTitleMessageDetailsError
      title: migrateApiToSpecHub400ErrorTitleMessageDetails
    MigrateApiToSpecHub400ErrorTypeNameMessageTitleError:
      type: object
      properties:
        type:
          type: string
          description: A short summary of the problem.
        name:
          type: string
          description: The error name.
        message:
          type: string
          description: The error message.
        title:
          type: string
          description: A short summary of the problem.
      title: MigrateApiToSpecHub400ErrorTypeNameMessageTitleError
    migrateApiToSpecHub400ErrorTypeNameMessageTitle:
      type: object
      properties:
        error:
          $ref: >-
            #/components/schemas/MigrateApiToSpecHub400ErrorTypeNameMessageTitleError
      title: migrateApiToSpecHub400ErrorTypeNameMessageTitle
    MigrateApiToSpecHubRequestBadRequestError:
      oneOf:
        - $ref: '#/components/schemas/migrateApiToSpecHub400ErrorTitleMessage'
        - $ref: '#/components/schemas/migrateApiToSpecHub400ErrorTitleMessageDetails'
        - $ref: '#/components/schemas/migrateApiToSpecHub400ErrorTypeNameMessageTitle'
      title: MigrateApiToSpecHubRequestBadRequestError
    commonErrorTypeTitleDetailStatusInstance:
      type: object
      properties:
        type:
          type: string
          format: uri-reference
          description: >-
            The [URI reference](https://www.rfc-editor.org/rfc/rfc3986) that
            identifies the type of problem.
        title:
          type: string
          description: A short summary of the problem.
        detail:
          type: string
          description: An explanation about the problem.
        status:
          type: integer
          description: The HTTP status code generated by the origin server.
        instance:
          type: string
          description: >-
            The URI reference that identifies the specific occurrence of the
            problem.
      title: commonErrorTypeTitleDetailStatusInstance
    CommonErrorTypeTitleDetailStatusType:
      oneOf:
        - type: string
          format: uri-reference
        - type: string
      title: CommonErrorTypeTitleDetailStatusType
    commonErrorTypeTitleDetailStatus:
      type: object
      properties:
        type:
          $ref: '#/components/schemas/CommonErrorTypeTitleDetailStatusType'
        title:
          type: string
          description: A short summary of the problem.
        detail:
          type: string
          description: Information about the error.
        status:
          type: integer
          description: The error's HTTP status code.
      title: commonErrorTypeTitleDetailStatus
    MigrateApiToSpecHubRequestForbiddenError:
      oneOf:
        - $ref: '#/components/schemas/commonErrorTypeTitleDetailStatus'
        - $ref: '#/components/schemas/commonErrorTypeTitleDetailStatusInstance'
      title: MigrateApiToSpecHubRequestForbiddenError
    CommonErrorTypeTitleDetailDetail:
      oneOf:
        - type: string
        - type: object
          additionalProperties:
            description: Any type
      description: Information about the error.
      title: CommonErrorTypeTitleDetailDetail
    commonErrorTypeTitleDetail:
      type: object
      properties:
        type:
          type: string
          description: The type of error.
        title:
          type: string
          description: A short summary of the problem.
        detail:
          $ref: '#/components/schemas/CommonErrorTypeTitleDetailDetail'
          description: Information about the error.
      title: commonErrorTypeTitleDetail
    CommonErrorNameMessageError:
      type: object
      properties:
        name:
          type: string
          description: The error name.
        message:
          type: string
          description: The error message.
      description: Information about the error.
      title: CommonErrorNameMessageError
    commonErrorNameMessage:
      type: object
      properties:
        error:
          $ref: '#/components/schemas/CommonErrorNameMessageError'
          description: Information about the error.
      title: commonErrorNameMessage
    MigrateApiToSpecHubRequestInternalServerError:
      oneOf:
        - $ref: '#/components/schemas/commonErrorTypeTitleDetail'
        - $ref: '#/components/schemas/commonErrorTypeTitleDetailStatus'
        - $ref: '#/components/schemas/commonErrorNameMessage'
      title: MigrateApiToSpecHubRequestInternalServerError
  securitySchemes:
    PostmanApiKey:
      type: apiKey
      in: header
      name: x-api-key
    scimApiKey:
      type: apiKey
      in: header
      name: Authorization
      description: >-
        A valid [SCIM API
        key](https://learning.postman.com/docs/administration/scim-provisioning/scim-provisioning-overview/#generating-scim-api-key)
        for calls to SCIM endpoints.
    basicAuth:
      type: http
      scheme: basic

```

## Examples

### Empty API Migration



**Request**

```json
undefined
```

**Response**

```json
{
  "message": "This API doesn't have any API Definition or Collection",
  "success": true
}
```

**SDK Code**

```python Empty API Migration
import requests

url = "https://api.getpostman.com/apis/90ca9f5a-c4c4-11ed-afa1-0242ac120002/spec-migrations"

headers = {
    "Accept": "application/vnd.api.v10+json",
    "x-api-key": "<apiKey>",
    "Content-Type": "application/json"
}

response = requests.post(url, headers=headers)

print(response.json())
```

```javascript Empty API Migration
const url = 'https://api.getpostman.com/apis/90ca9f5a-c4c4-11ed-afa1-0242ac120002/spec-migrations';
const options = {
  method: 'POST',
  headers: {
    Accept: 'application/vnd.api.v10+json',
    'x-api-key': '<apiKey>',
    'Content-Type': 'application/json'
  },
  body: undefined
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go Empty API Migration
package main

import (
	"fmt"
	"net/http"
	"io"
)

func main() {

	url := "https://api.getpostman.com/apis/90ca9f5a-c4c4-11ed-afa1-0242ac120002/spec-migrations"

	req, _ := http.NewRequest("POST", url, nil)

	req.Header.Add("Accept", "application/vnd.api.v10+json")
	req.Header.Add("x-api-key", "<apiKey>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby Empty API Migration
require 'uri'
require 'net/http'

url = URI("https://api.getpostman.com/apis/90ca9f5a-c4c4-11ed-afa1-0242ac120002/spec-migrations")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Accept"] = 'application/vnd.api.v10+json'
request["x-api-key"] = '<apiKey>'
request["Content-Type"] = 'application/json'

response = http.request(request)
puts response.read_body
```

```java Empty API Migration
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.getpostman.com/apis/90ca9f5a-c4c4-11ed-afa1-0242ac120002/spec-migrations")
  .header("Accept", "application/vnd.api.v10+json")
  .header("x-api-key", "<apiKey>")
  .header("Content-Type", "application/json")
  .asString();
```

```php Empty API Migration
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.getpostman.com/apis/90ca9f5a-c4c4-11ed-afa1-0242ac120002/spec-migrations', [
  'headers' => [
    'Accept' => 'application/vnd.api.v10+json',
    'Content-Type' => 'application/json',
    'x-api-key' => '<apiKey>',
  ],
]);

echo $response->getBody();
```

```csharp Empty API Migration
using RestSharp;

var client = new RestClient("https://api.getpostman.com/apis/90ca9f5a-c4c4-11ed-afa1-0242ac120002/spec-migrations");
var request = new RestRequest(Method.POST);
request.AddHeader("Accept", "application/vnd.api.v10+json");
request.AddHeader("x-api-key", "<apiKey>");
request.AddHeader("Content-Type", "application/json");
IRestResponse response = client.Execute(request);
```

```swift Empty API Migration
import Foundation

let headers = [
  "Accept": "application/vnd.api.v10+json",
  "x-api-key": "<apiKey>",
  "Content-Type": "application/json"
]

let request = NSMutableURLRequest(url: NSURL(string: "https://api.getpostman.com/apis/90ca9f5a-c4c4-11ed-afa1-0242ac120002/spec-migrations")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```

### Successful Response



**Request**

```json
undefined
```

**Response**

```json
{
  "message": "Moving to Spec Hub started successfully",
  "success": true
}
```

**SDK Code**

```python Successful Response
import requests

url = "https://api.getpostman.com/apis/90ca9f5a-c4c4-11ed-afa1-0242ac120002/spec-migrations"

headers = {
    "Accept": "application/vnd.api.v10+json",
    "x-api-key": "<apiKey>",
    "Content-Type": "application/json"
}

response = requests.post(url, headers=headers)

print(response.json())
```

```javascript Successful Response
const url = 'https://api.getpostman.com/apis/90ca9f5a-c4c4-11ed-afa1-0242ac120002/spec-migrations';
const options = {
  method: 'POST',
  headers: {
    Accept: 'application/vnd.api.v10+json',
    'x-api-key': '<apiKey>',
    'Content-Type': 'application/json'
  },
  body: undefined
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go Successful Response
package main

import (
	"fmt"
	"net/http"
	"io"
)

func main() {

	url := "https://api.getpostman.com/apis/90ca9f5a-c4c4-11ed-afa1-0242ac120002/spec-migrations"

	req, _ := http.NewRequest("POST", url, nil)

	req.Header.Add("Accept", "application/vnd.api.v10+json")
	req.Header.Add("x-api-key", "<apiKey>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby Successful Response
require 'uri'
require 'net/http'

url = URI("https://api.getpostman.com/apis/90ca9f5a-c4c4-11ed-afa1-0242ac120002/spec-migrations")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Accept"] = 'application/vnd.api.v10+json'
request["x-api-key"] = '<apiKey>'
request["Content-Type"] = 'application/json'

response = http.request(request)
puts response.read_body
```

```java Successful Response
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.getpostman.com/apis/90ca9f5a-c4c4-11ed-afa1-0242ac120002/spec-migrations")
  .header("Accept", "application/vnd.api.v10+json")
  .header("x-api-key", "<apiKey>")
  .header("Content-Type", "application/json")
  .asString();
```

```php Successful Response
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.getpostman.com/apis/90ca9f5a-c4c4-11ed-afa1-0242ac120002/spec-migrations', [
  'headers' => [
    'Accept' => 'application/vnd.api.v10+json',
    'Content-Type' => 'application/json',
    'x-api-key' => '<apiKey>',
  ],
]);

echo $response->getBody();
```

```csharp Successful Response
using RestSharp;

var client = new RestClient("https://api.getpostman.com/apis/90ca9f5a-c4c4-11ed-afa1-0242ac120002/spec-migrations");
var request = new RestRequest(Method.POST);
request.AddHeader("Accept", "application/vnd.api.v10+json");
request.AddHeader("x-api-key", "<apiKey>");
request.AddHeader("Content-Type", "application/json");
IRestResponse response = client.Execute(request);
```

```swift Successful Response
import Foundation

let headers = [
  "Accept": "application/vnd.api.v10+json",
  "x-api-key": "<apiKey>",
  "Content-Type": "application/json"
]

let request = NSMutableURLRequest(url: NSURL(string: "https://api.getpostman.com/apis/90ca9f5a-c4c4-11ed-afa1-0242ac120002/spec-migrations")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```

### Migrate to Exisiting Workspace



**Request**

```json
{
  "workspaceId": "1f0df51a-8658-4ee8-a2a1-d2567dfa09a9"
}
```

**Response**

```json
{
  "message": "This API doesn't have any API Definition or Collection",
  "success": true
}
```

**SDK Code**

```python Migrate to Exisiting Workspace
import requests

url = "https://api.getpostman.com/apis/90ca9f5a-c4c4-11ed-afa1-0242ac120002/spec-migrations"

payload = { "workspaceId": "1f0df51a-8658-4ee8-a2a1-d2567dfa09a9" }
headers = {
    "Accept": "application/vnd.api.v10+json",
    "x-api-key": "<apiKey>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```javascript Migrate to Exisiting Workspace
const url = 'https://api.getpostman.com/apis/90ca9f5a-c4c4-11ed-afa1-0242ac120002/spec-migrations';
const options = {
  method: 'POST',
  headers: {
    Accept: 'application/vnd.api.v10+json',
    'x-api-key': '<apiKey>',
    'Content-Type': 'application/json'
  },
  body: '{"workspaceId":"1f0df51a-8658-4ee8-a2a1-d2567dfa09a9"}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go Migrate to Exisiting Workspace
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.getpostman.com/apis/90ca9f5a-c4c4-11ed-afa1-0242ac120002/spec-migrations"

	payload := strings.NewReader("{\n  \"workspaceId\": \"1f0df51a-8658-4ee8-a2a1-d2567dfa09a9\"\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Accept", "application/vnd.api.v10+json")
	req.Header.Add("x-api-key", "<apiKey>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby Migrate to Exisiting Workspace
require 'uri'
require 'net/http'

url = URI("https://api.getpostman.com/apis/90ca9f5a-c4c4-11ed-afa1-0242ac120002/spec-migrations")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Accept"] = 'application/vnd.api.v10+json'
request["x-api-key"] = '<apiKey>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"workspaceId\": \"1f0df51a-8658-4ee8-a2a1-d2567dfa09a9\"\n}"

response = http.request(request)
puts response.read_body
```

```java Migrate to Exisiting Workspace
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.getpostman.com/apis/90ca9f5a-c4c4-11ed-afa1-0242ac120002/spec-migrations")
  .header("Accept", "application/vnd.api.v10+json")
  .header("x-api-key", "<apiKey>")
  .header("Content-Type", "application/json")
  .body("{\n  \"workspaceId\": \"1f0df51a-8658-4ee8-a2a1-d2567dfa09a9\"\n}")
  .asString();
```

```php Migrate to Exisiting Workspace
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.getpostman.com/apis/90ca9f5a-c4c4-11ed-afa1-0242ac120002/spec-migrations', [
  'body' => '{
  "workspaceId": "1f0df51a-8658-4ee8-a2a1-d2567dfa09a9"
}',
  'headers' => [
    'Accept' => 'application/vnd.api.v10+json',
    'Content-Type' => 'application/json',
    'x-api-key' => '<apiKey>',
  ],
]);

echo $response->getBody();
```

```csharp Migrate to Exisiting Workspace
using RestSharp;

var client = new RestClient("https://api.getpostman.com/apis/90ca9f5a-c4c4-11ed-afa1-0242ac120002/spec-migrations");
var request = new RestRequest(Method.POST);
request.AddHeader("Accept", "application/vnd.api.v10+json");
request.AddHeader("x-api-key", "<apiKey>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"workspaceId\": \"1f0df51a-8658-4ee8-a2a1-d2567dfa09a9\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Migrate to Exisiting Workspace
import Foundation

let headers = [
  "Accept": "application/vnd.api.v10+json",
  "x-api-key": "<apiKey>",
  "Content-Type": "application/json"
]
let parameters = ["workspaceId": "1f0df51a-8658-4ee8-a2a1-d2567dfa09a9"] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api.getpostman.com/apis/90ca9f5a-c4c4-11ed-afa1-0242ac120002/spec-migrations")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```

### Migrate to New Workspace



**Request**

```json
{
  "workspaceId": "1f0df51a-8658-4ee8-a2a1-d2567dfa09a9",
  "workspaceInfo": {
    "name": "API Workspace"
  }
}
```

**Response**

```json
{
  "message": "This API doesn't have any API Definition or Collection",
  "success": true
}
```

**SDK Code**

```python Migrate to New Workspace
import requests

url = "https://api.getpostman.com/apis/90ca9f5a-c4c4-11ed-afa1-0242ac120002/spec-migrations"

payload = {
    "workspaceId": "1f0df51a-8658-4ee8-a2a1-d2567dfa09a9",
    "workspaceInfo": { "name": "API Workspace" }
}
headers = {
    "Accept": "application/vnd.api.v10+json",
    "x-api-key": "<apiKey>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```javascript Migrate to New Workspace
const url = 'https://api.getpostman.com/apis/90ca9f5a-c4c4-11ed-afa1-0242ac120002/spec-migrations';
const options = {
  method: 'POST',
  headers: {
    Accept: 'application/vnd.api.v10+json',
    'x-api-key': '<apiKey>',
    'Content-Type': 'application/json'
  },
  body: '{"workspaceId":"1f0df51a-8658-4ee8-a2a1-d2567dfa09a9","workspaceInfo":{"name":"API Workspace"}}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go Migrate to New Workspace
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.getpostman.com/apis/90ca9f5a-c4c4-11ed-afa1-0242ac120002/spec-migrations"

	payload := strings.NewReader("{\n  \"workspaceId\": \"1f0df51a-8658-4ee8-a2a1-d2567dfa09a9\",\n  \"workspaceInfo\": {\n    \"name\": \"API Workspace\"\n  }\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Accept", "application/vnd.api.v10+json")
	req.Header.Add("x-api-key", "<apiKey>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby Migrate to New Workspace
require 'uri'
require 'net/http'

url = URI("https://api.getpostman.com/apis/90ca9f5a-c4c4-11ed-afa1-0242ac120002/spec-migrations")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Accept"] = 'application/vnd.api.v10+json'
request["x-api-key"] = '<apiKey>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"workspaceId\": \"1f0df51a-8658-4ee8-a2a1-d2567dfa09a9\",\n  \"workspaceInfo\": {\n    \"name\": \"API Workspace\"\n  }\n}"

response = http.request(request)
puts response.read_body
```

```java Migrate to New Workspace
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.getpostman.com/apis/90ca9f5a-c4c4-11ed-afa1-0242ac120002/spec-migrations")
  .header("Accept", "application/vnd.api.v10+json")
  .header("x-api-key", "<apiKey>")
  .header("Content-Type", "application/json")
  .body("{\n  \"workspaceId\": \"1f0df51a-8658-4ee8-a2a1-d2567dfa09a9\",\n  \"workspaceInfo\": {\n    \"name\": \"API Workspace\"\n  }\n}")
  .asString();
```

```php Migrate to New Workspace
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.getpostman.com/apis/90ca9f5a-c4c4-11ed-afa1-0242ac120002/spec-migrations', [
  'body' => '{
  "workspaceId": "1f0df51a-8658-4ee8-a2a1-d2567dfa09a9",
  "workspaceInfo": {
    "name": "API Workspace"
  }
}',
  'headers' => [
    'Accept' => 'application/vnd.api.v10+json',
    'Content-Type' => 'application/json',
    'x-api-key' => '<apiKey>',
  ],
]);

echo $response->getBody();
```

```csharp Migrate to New Workspace
using RestSharp;

var client = new RestClient("https://api.getpostman.com/apis/90ca9f5a-c4c4-11ed-afa1-0242ac120002/spec-migrations");
var request = new RestRequest(Method.POST);
request.AddHeader("Accept", "application/vnd.api.v10+json");
request.AddHeader("x-api-key", "<apiKey>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"workspaceId\": \"1f0df51a-8658-4ee8-a2a1-d2567dfa09a9\",\n  \"workspaceInfo\": {\n    \"name\": \"API Workspace\"\n  }\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Migrate to New Workspace
import Foundation

let headers = [
  "Accept": "application/vnd.api.v10+json",
  "x-api-key": "<apiKey>",
  "Content-Type": "application/json"
]
let parameters = [
  "workspaceId": "1f0df51a-8658-4ee8-a2a1-d2567dfa09a9",
  "workspaceInfo": ["name": "API Workspace"]
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api.getpostman.com/apis/90ca9f5a-c4c4-11ed-afa1-0242ac120002/spec-migrations")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```

### Migrate Git-Connected Mono-Repo to New Workspace



**Request**

```json
{
  "gitInfo": {
    "path": "/spaceships"
  },
  "workspaceId": "1f0df51a-8658-4ee8-a2a1-d2567dfa09a9",
  "workspaceInfo": {
    "name": "API Workspace"
  }
}
```

**Response**

```json
{
  "message": "This API doesn't have any API Definition or Collection",
  "success": true
}
```

**SDK Code**

```python Migrate Git-Connected Mono-Repo to New Workspace
import requests

url = "https://api.getpostman.com/apis/90ca9f5a-c4c4-11ed-afa1-0242ac120002/spec-migrations"

payload = {
    "gitInfo": { "path": "/spaceships" },
    "workspaceId": "1f0df51a-8658-4ee8-a2a1-d2567dfa09a9",
    "workspaceInfo": { "name": "API Workspace" }
}
headers = {
    "Accept": "application/vnd.api.v10+json",
    "x-api-key": "<apiKey>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```javascript Migrate Git-Connected Mono-Repo to New Workspace
const url = 'https://api.getpostman.com/apis/90ca9f5a-c4c4-11ed-afa1-0242ac120002/spec-migrations';
const options = {
  method: 'POST',
  headers: {
    Accept: 'application/vnd.api.v10+json',
    'x-api-key': '<apiKey>',
    'Content-Type': 'application/json'
  },
  body: '{"gitInfo":{"path":"/spaceships"},"workspaceId":"1f0df51a-8658-4ee8-a2a1-d2567dfa09a9","workspaceInfo":{"name":"API Workspace"}}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go Migrate Git-Connected Mono-Repo to New Workspace
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.getpostman.com/apis/90ca9f5a-c4c4-11ed-afa1-0242ac120002/spec-migrations"

	payload := strings.NewReader("{\n  \"gitInfo\": {\n    \"path\": \"/spaceships\"\n  },\n  \"workspaceId\": \"1f0df51a-8658-4ee8-a2a1-d2567dfa09a9\",\n  \"workspaceInfo\": {\n    \"name\": \"API Workspace\"\n  }\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Accept", "application/vnd.api.v10+json")
	req.Header.Add("x-api-key", "<apiKey>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby Migrate Git-Connected Mono-Repo to New Workspace
require 'uri'
require 'net/http'

url = URI("https://api.getpostman.com/apis/90ca9f5a-c4c4-11ed-afa1-0242ac120002/spec-migrations")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Accept"] = 'application/vnd.api.v10+json'
request["x-api-key"] = '<apiKey>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"gitInfo\": {\n    \"path\": \"/spaceships\"\n  },\n  \"workspaceId\": \"1f0df51a-8658-4ee8-a2a1-d2567dfa09a9\",\n  \"workspaceInfo\": {\n    \"name\": \"API Workspace\"\n  }\n}"

response = http.request(request)
puts response.read_body
```

```java Migrate Git-Connected Mono-Repo to New Workspace
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.getpostman.com/apis/90ca9f5a-c4c4-11ed-afa1-0242ac120002/spec-migrations")
  .header("Accept", "application/vnd.api.v10+json")
  .header("x-api-key", "<apiKey>")
  .header("Content-Type", "application/json")
  .body("{\n  \"gitInfo\": {\n    \"path\": \"/spaceships\"\n  },\n  \"workspaceId\": \"1f0df51a-8658-4ee8-a2a1-d2567dfa09a9\",\n  \"workspaceInfo\": {\n    \"name\": \"API Workspace\"\n  }\n}")
  .asString();
```

```php Migrate Git-Connected Mono-Repo to New Workspace
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.getpostman.com/apis/90ca9f5a-c4c4-11ed-afa1-0242ac120002/spec-migrations', [
  'body' => '{
  "gitInfo": {
    "path": "/spaceships"
  },
  "workspaceId": "1f0df51a-8658-4ee8-a2a1-d2567dfa09a9",
  "workspaceInfo": {
    "name": "API Workspace"
  }
}',
  'headers' => [
    'Accept' => 'application/vnd.api.v10+json',
    'Content-Type' => 'application/json',
    'x-api-key' => '<apiKey>',
  ],
]);

echo $response->getBody();
```

```csharp Migrate Git-Connected Mono-Repo to New Workspace
using RestSharp;

var client = new RestClient("https://api.getpostman.com/apis/90ca9f5a-c4c4-11ed-afa1-0242ac120002/spec-migrations");
var request = new RestRequest(Method.POST);
request.AddHeader("Accept", "application/vnd.api.v10+json");
request.AddHeader("x-api-key", "<apiKey>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"gitInfo\": {\n    \"path\": \"/spaceships\"\n  },\n  \"workspaceId\": \"1f0df51a-8658-4ee8-a2a1-d2567dfa09a9\",\n  \"workspaceInfo\": {\n    \"name\": \"API Workspace\"\n  }\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Migrate Git-Connected Mono-Repo to New Workspace
import Foundation

let headers = [
  "Accept": "application/vnd.api.v10+json",
  "x-api-key": "<apiKey>",
  "Content-Type": "application/json"
]
let parameters = [
  "gitInfo": ["path": "/spaceships"],
  "workspaceId": "1f0df51a-8658-4ee8-a2a1-d2567dfa09a9",
  "workspaceInfo": ["name": "API Workspace"]
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api.getpostman.com/apis/90ca9f5a-c4c4-11ed-afa1-0242ac120002/spec-migrations")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```