Public and Private APIs

API definitions in SwaggerHub can be public and private. Public APIs are visible to anyone, even to those who do not have a SwaggerHub account. Private APIs are visible only to the API owner and designers and consumers (the users who were explicitly granted access to the API).

You can set the public or private status for each API version individually.

Make your API public or private

You make your API public or private when creating or importing it by selecting from the Visibility field:

Creating a public or private API

You can also change the visibility status of an existing API at any time. To do this, you must be the API’s owner or a designer/consumer with access to the resource:

  1. Open the API page in SwaggerHub.

  2. If your API has several versions, select the version you want to make private or public:

    Selecting an API version
  3. Click public.png to make the version private or private.png to make it public.

See if an API is public or private

Private APIs appear with the PRIVATE label on the SwaggerHub dashboard, in search results and on the API definition page. Note that different versions of the same API can have different visibility statuses.

Private API

Click the image to enlarge it.

Control who can access your private API

By default, a private API is visible only to the organization member who created it. To give other people and teams access to your private API, you need to add them to the API as designers or consumers. Designers have read-write access, and consumers have read-only access to an API. Note that members need a SwaggerHub account.

To add collaborators:

  1. Open the API page in SwaggerHub.

  2. In the top right corner, click share.png.

  3. Type the user name, user email, or team name to add. Select a role for each member.

    Sharing and roles
  4. Click Save.

The specified users will get an email notification that they have been given access to an API.

Change visibility via CLI

Use SwaggerHub CLI to change the visibility of your APIs from the command line.

To change API visibility to Private:

swaggerhub api:update --visibility=private OWNER/API_NAME/VERSION 

To change API visibility to Public:

swaggerhub api:update --visibility=public OWNER/API_NAME/VERSION 

See Also

Publication date: