Forum Discussion

confuzed's avatar
confuzed
New Contributor
20 days ago
Solved

CLI output is not json when "--format json" used with "connect server create"

When running `op --format json connect server create "My Server" --vaults "MyVault"`, I expect the output to be JSON, an only JSON, so that my script can safely consume the output. I need to extract the server's ID from the output for use in following commands.

Example output:

> op --format json connect server create "My Server" --vaults "MyVault"

Set up a Connect server.
UUID: <REDACTED>
Credentials file: <REDACTED>\1password-credentials.json

 

  • Hi confuzed​,

    Thanks for reaching out. thanks for the feedback, I'll send this along to the team.  In the mean time as a work around you can use the following to retrieve the JSON version of the server info:

    op connect server get "Demo Server" --format json

    it will come back like this

    ➜  Connect op connect server get "Demo Server" --format json
    {
      "id": "TRMT2AZWWRE65JAHY{REDACTED}",
      "name": "demo SErver",
      "state": "ACTIVE",
      "created_at": "2025-06-27T16:05:12Z",
      "creator_id": "FIVA23HWMBETFC{REDACTED}",
      "tokens_version": 1
    }

    Let us know if you need more help!  

    All the best, 

    Phil

4 Replies

  • confuzed's avatar
    confuzed
    New Contributor

    I think as long as it is simple to get the ID back from the API, then having duplicate names doesn't really matter, and seems to be consistent with other parts of the API. I would just vote strongly for ensuring that the `--format json` option works consistently on all of the CRUD operations.

    Thanks again for discussing this, and forwarding it to the team.

  • confuzed's avatar
    confuzed
    New Contributor

    Thank you for the suggestion. Unfortunately the reason I wanted to grab the ID from the output in the first place was because the API allows you to create multiple servers with the same name, causing other commands to fail when using the name to identify the server, which will be a problem with the suggestion. For now I've just grabbed the text output and extracted the ID via a regex, but it would be great to have a stable JSON output to use instead, I'll look out for the fix in a future release.

  • Hi confuzed​,

    Thanks for reaching out. thanks for the feedback, I'll send this along to the team.  In the mean time as a work around you can use the following to retrieve the JSON version of the server info:

    op connect server get "Demo Server" --format json

    it will come back like this

    ➜  Connect op connect server get "Demo Server" --format json
    {
      "id": "TRMT2AZWWRE65JAHY{REDACTED}",
      "name": "demo SErver",
      "state": "ACTIVE",
      "created_at": "2025-06-27T16:05:12Z",
      "creator_id": "FIVA23HWMBETFC{REDACTED}",
      "tokens_version": 1
    }

    Let us know if you need more help!  

    All the best, 

    Phil