Updating my API through a script

I have an API that I want to update through a bash script using curl:
The curl is:

curl -v \
      -H "X-Api-Key: $POSTMAN_API_KEY" \
      -H "Accept: application/vnd.api.v10+json" \
      -F "type=schema" \
      -F "language=openapi3" \
      -F "file=@$OPENAPI_FILE_CLEAN" \
      "https://api.getpostman.com/apis/$API_ID/schemas"

I have even tried with files=@… and with files[ ]=@… and I am getting in the three cases:
{“type”:“invalidParamError”,“title”:“Invalid request body”,“detail”:“Missing parameter: ‘files’”}

I have an API and I also tested with a smaller sample:

openapi: 3.0.0
info:
  title: Simple Test API
  version: 1.0.0
paths:
  /ping:
    get:
      summary: Health check
      responses:
        '200':
          description: OK.

It works to import directly from postman, but I want to do it from a bash.
What seems to be the problem

Hey @mbraidy :waving_hand:

Welcome back to the Postman Community! :postman:

Are you using this documentation for the structure of your request?

Hi, @mbraidy!
The request you are trying to execute is the POST /api/{ApiId}/schemas. You can check an example here.
Notice:

  • The request method must be POST
  • The request body requires a type and a list of files.

In your code you are using file instead of files (which is a list, not a single file).

An example of curl request (generated in Postman) would be:

curl --location --globoff 'https://api.getpostman.com/apis/{{apiId}}/schemas' \
--header 'Accept: application/vnd.api.v10+json' \
--header 'Content-Type: application/json' \
--header 'X-API-Key;' \
--data '{
    "type": "{{schemaType}}",
    "files": [
        {
            "path": "{{filePath1}}",
            "content": "{{content1}}"
        },
         {
            "path": "{{filePath2}}",
            "content": "{{content2}}"
        },
         {
            "path": "{{filePath3}}",
            "content": "{{content3}}"
        },
         {
            "path": "{{filePath4}}",
            "content": "{{content4}}"
        }
    ]
}'

Thank you for your reply. It helped by setting me on the right track. However, now I am getting another error.
Here is my request using the api

curl --location --globoff --request PUT 'https://api.getpostman.com/apis/{{apiId}}' \
--header 'Content-Type: application/json' \
--header 'Accept: application/vnd.api.v10+json"' \
--header 'X-Api-Key: ••••••' \
--data '{
    "type": "schema",
    "language": "openapi3",
    "schemaFormat": "application/json",
    "content": {
        "openapi": "3.0.0",
        "info": {
       ...
}}}'

The response is:

{
    "error": {
        "name": "instanceNotFoundError",
        "message": "Missing request header. For v10 and later APIs, ensure that your request sends the \"application/vnd.api.v10+json\" Accept header."
    }
}

In your example, you have an extra " character in that header:

--header 'Accept: application/vnd.api.v10+json"' \

Is that the issue?

OOPSy…thank you. I got something now 200 OK
and the response is

{
    "updatedBy": ".......",
    "updatedAt": "2025-04-03T09:10:46.000Z",
    "description": null,
    "name": "Experimental",
    "id": "...................",
    "summary": null,
    "createdBy": "....,
    "createdAt": "2025-03-31T05:36:42.000Z"
}

However the API is not showing any change

Based only on that response - We can’t actually see what’s been done here.

We’re unable to see what you have in front of you, without more visual information about what it looked like before and what you’re expecting to see changed after your update - It’s going to be difficult for us to suggest anything.

Are you looking for a change in the UI? Does refreshing the UI show the change?

It looks like you’re using this request but the request body you have sent doesn’t match that request.

I have an API that I want to update. I use a bash script that:

  • Download a collection from Postman using
 curl -X GET "${POSTMAN_API_URL}/collections/${COLLECTION_UID}" \
    -H "X-Api-Key: ${POSTMAN_API_KEY}" \
    -H "Cache-Control: no-cache" \
    -o "${EXPORTED_COLLECTION}"

  curl -X GET "${POSTMAN_API_URL}/environments/${ENVIRONMENT_UID}" \
    -H "X-Api-Key: ${POSTMAN_API_KEY}" \
    -H "Cache-Control: no-cache" \
    -o "${EXPORTED_ENVIRONMENT}"

  • Convert the collection to openAPI3 using ‘postman-to-openapi’
  • Try to upload the openAPI3 to API point using:
  jq -Rs --arg type "schema" --arg lang "openapi3" --arg format "application/json" \
    '{type: $type, language: $lang, schemaFormat: $format, content: .}' <"$OPENAPI_FILE_CLEAN" |
    curl --silent --show-error --location \
      --request PUT "$POSTMAN_API_URL/apis/$API_ID" \
      -H "X-API-Key: $POSTMAN_API_KEY" \
      -H "Content-Type: application/json" \
      -H "Accept: application/vnd.api.v10+json" \
      --output "$TMP_BODY" \
      --write-out "%{http_code}" \
      --data @- >"$TMP_STATUS"

  HTTP_STATUS=$(cat "$TMP_STATUS")
  SCHEMA_RESPONSE=$(cat "$TMP_BODY")

What I expect to see is my API in postman updated with openAPI3

Hi, @mbraidy!
The API PUT endpoint only updates the API resource, not the schema files. To update files, you have to use the schema files APIs (the PUT operation).
Basically, an API has a schema, and the schema has files that you can update.
You can find information and code related to the APIs APIs in this article.