> ## Documentation Index
> Fetch the complete documentation index at: https://www.openpmm.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# OpenPMM API quickstart

> Create an API key, find a Destination, and publish one Post safely.

This guide creates a draft before it publishes the same Post.

## Before you begin

You need an OpenPMM Account and access to a Workspace. If you do not have one,
[create an account from an agent](/docs/guides/create-account). You can also sign in
at [app.openpmm.com](https://app.openpmm.com).

<Steps>
  <Step title="Create an API key">
    Open your workspace, then go to **Workspace settings** and select **API keys**.
    Create a key and copy it immediately. OpenPMM shows the secret one time.
  </Step>

  <Step title="Set the API key">
    Set the API key in your shell. Do not commit it.

    ```bash theme={null}
    export OPENPMM_API_KEY="your_api_key"
    ```
  </Step>

  <Step title="Verify the credential">
    Request the identity attached to the key.

    ```bash theme={null}
    curl --request GET \
      --url https://api.openpmm.com/v1/account \
      --header "Authorization: Bearer $OPENPMM_API_KEY"
    ```

    The response shows the credential environment, workspace access mode, scopes, and expiry time.
  </Step>

  <Step title="List workspaces">
    List the workspaces that the credential can use.

    ```bash theme={null}
    curl --request GET \
      --url https://api.openpmm.com/v1/workspaces \
      --header "Authorization: Bearer $OPENPMM_API_KEY"
    ```

    Copy a workspace `id` from the response. Set it in your shell.

    ```bash theme={null}
    export OPENPMM_WORKSPACE_ID="your_workspace_id"
    ```
  </Step>

  <Step title="List destinations">
    Check which connected social accounts are available.

    ```bash theme={null}
    curl --request GET \
      --url "https://api.openpmm.com/v1/workspaces/$OPENPMM_WORKSPACE_ID/destinations" \
      --header "Authorization: Bearer $OPENPMM_API_KEY"
    ```

    Copy one X Destination `id`. Set it in your shell.

    ```bash theme={null}
    export OPENPMM_DESTINATION_ID="your_destination_id"
    ```
  </Step>

  <Step title="Create a draft Post">
    A draft does not contact the provider.

    ```bash theme={null}
    curl --request POST \
      --url "https://api.openpmm.com/v1/workspaces/$OPENPMM_WORKSPACE_ID/posts" \
      --header "Authorization: Bearer $OPENPMM_API_KEY" \
      --header "Content-Type: application/json" \
      --data '{"when":"draft","group":"quickstart","posts":[{"channel":"x","body":["Hello from OpenPMM"],"media":[],"destination_options":null}]}'
    ```

    Store the returned Post `id` and `version`.
  </Step>

  <Step title="Publish the Post">
    <Warning>
      This request creates public provider content. Review the Post first.
    </Warning>

    Send the Post ID, version, and Destination ID.
    Add a unique idempotency key.

    ```bash theme={null}
    curl --request POST \
      --url "https://api.openpmm.com/v1/workspaces/$OPENPMM_WORKSPACE_ID/posts/publish" \
      --header "Authorization: Bearer $OPENPMM_API_KEY" \
      --header "Content-Type: application/json" \
      --header "Idempotency-Key: quickstart-001" \
      --data '{"confirmed":true,"when":"now","time_zone":"UTC","posts":[{"id":"send_01JABCDEF","version":1,"destination_id":"'"$OPENPMM_DESTINATION_ID"'"}]}'
    ```
  </Step>

  <Step title="Inspect the Post">
    Use the returned Post ID.

    ```bash theme={null}
    curl --request GET \
      --url "https://api.openpmm.com/v1/workspaces/$OPENPMM_WORKSPACE_ID/posts/send_01JABCDEF?include=attempts" \
      --header "Authorization: Bearer $OPENPMM_API_KEY"
    ```

    Read `terminal`, `action_required`, `retry_safety`, and
    `available_actions`. Store the receipt when the Post is published.
  </Step>
</Steps>

<Warning>
  Treat an API key like a password. Keep production keys in a server-side secret store. Do not put a key in source control or client code.
</Warning>

Next, [use the CLI](/docs/cli/overview), [connect a destination](/docs/guides/connect-a-destination), or [create a post](/docs/guides/publish-posts).
