Using Postman with the PacketFabric API

API requests typically return more information than is visible in the portal. This can be helpful when troubleshooting issues.

If you do not already have Postman installed, you can download it here: https://www.postman.com/downloads/

API authentication

You can retrieve a token by logging in via the API and getting a session token or by generating an API key in the portal.

Every request you send to the PacketFabric API must include a token. See Create and send a request below for details on how to include the token in requests.

Session token

API key

Submit a multi-factor authentication code

If you have two factor authentication enabled, you will be prompted to enter a code.

  1. Complete the steps above to retrieve your bearer token.

  2. Using the same request form, click the Authorization tab.

  3. From the Type drop-down menu, select Bearer Token.

  4. Paste your token into the field provided.

    Authorization tab

  5. Add the mfa endpoint to the request URL: https://api.packetfabric.com/v2/auth/login/mfa

  6. Select the Body sub-tab and replace your username and password with your authentication code (enclosed in quotation marks):

    {
      "authentication_code": "123456"
    }
  7. This should return a simple success message, and then you can begin sending other requests.

Create and send a request

  1. Click the plus icon to open a new request form.

  2. Click the Authorization tab.

  3. From the Type drop-down menu, select Bearer Token.

  4. Paste your token into the field provided.

    Authorization tab

    TIP: If you will be using Postman frequently with our API, you can create a collection in which the token is automatically added to all new requests.

    This also means that when you need to retrieve a new token, you only need to update it in one location. For more information, see the Postman documentation on creating collections.

  5. Review our API reference to find the request you would like to send.

  6. Click the drop-down menu next to the request name. Copy the URL.

    API ref down arrow

  7. Paste the PacketFabric URL into the request form.

  8. If the URL contains a parameter (indicated by curly braces), replace it with the appropriate information.

    Many APIs require an identifier such as a circuit ID. If you don’t know the ID, you can find it in two places:

    • Use the API - There are several APIs that return device or service lists. For example, the ports request returns a list of your ports, which includes all their circuit IDs.

    • Use the portal - Circuit IDs can be found on service details pages. They start with PF and are followed by the service type, POP, and a numeric ID. For a list of service type acronyms in circuit IDs, see the PacketFabric FAQ.

      However, note that if you sign in to the portal to get the circuit ID, you will need to retrieve a fresh token in Postman when you return.

  9. Click Send.

“Not authorized” error

This has several causes:

  • Your bearer token is no longer valid. Generate a new session token or API key (see above).
  • You forgot to include a bearer token with your API request.
  • You might not have permission to complete the API request. For more information on what actions users can take, see User Permissions.
  • Occasionally this error is from a malformed API request. Check to ensure there are no formatting errors in your parameters.

“Invalid value” error

This is typically due to entering a string parameter in the JSON body without enclosing it in quotes. Boolean (true/false) and integers do not need surrounding quotes.

For example, the API call to create a dedicated Google connection includes strings, a boolean value, and an integer.

{
  "account_uuid": "a2115890-ed02-4795-a6dd-c485bec3529c",
  "description": "Connection for uploading cute cat pics",
  "zone": "A",
  "pop": "DAL1",
  "subscription_term": 24,
  "service_class": "longhaul",
  "autoneg": false,
  "speed": "10Gbps"
}

Our API reference lists each parameter type:

screenshot of reference docs with the param type highlighted