Update Opportunity Draft | Rankhog Docs

API Reference

Update Opportunity Draft

Edit one opportunity's linked Reddit draft, or write its first draft with expectedRevision 0.

Server URLhttps://api.rankhog.com/

POST

``/agent/v1/opportunities/draft

Send

Authorization

Body

Edit one opportunity's linked Reddit draft, or write its first draft with expectedRevision 0. Typed text takes Reddit's limits: a comment or reply up to 10,000 characters, a post title up to 300 and a post body up to 40,000. Direct saves immediately and costs nothing; audited mode saves first, then checks the saved revision. A conversation with no Reddit action yet refuses. Changes retain the requesting actor attribution. Cache policy: live. Idempotency: required. Auth modes: api_key, mcp_oauth, session_bearer.

Authorization

apiKeyAuth

AuthorizationBearer

Rankhog organization API key sent as Authorization: Bearer rhog_....

In: header

Request Body

application/json

TypeScript Definitions

Use the request body type in TypeScript.

Copy

managedRedditAccountId*string

Length1 <= length <= 160

organizationId*string

Length1 <= length <= 160

websiteId*string

Length1 <= length <= 160

idempotencyKey*string

Length1 <= length <= 160

body*string

The text, as Reddit Markdown. Up to 10,000 characters for a comment or reply and 40,000 for a post body (Reddit's own limits); the response names the exact limit when it is over.

Length1 <= length <= 40000

expectedRevision*integer

The draft revision being edited. Serves as the concurrency token; a mismatch rejects the save. Use 0 to write the first draft of an opportunity that has none (a new post or an undrafted find); the save creates revision 1.

Range0 <= value

mode?string

Direct saves immediately. Audit saves first and then checks that saved revision without changing it.

Default"direct"Value in"audit" | "direct"

opportunityId*string

Length1 <= length <= 160

title?string|null

A post's title, one line, up to 300 characters. Required for a post; ignored for a comment or reply.

Length1 <= length <= 300

Response Body

200 application/json

400 application/json

401 application/json

402 application/json

403 application/json

404 application/json

409 application/json

422 application/json

500 application/json

cURL

JavaScript

Go

Python

Java

C#

curl -X POST "https://api.rankhog.com/agent/v1/opportunities/draft" \
  -H "Authorization: Bearer " \
  -H "Content-Type: application/json" \
  -d '{
    "idempotencyKey": "edit-draft-1",
    "managedRedditAccountId": "mra_2x9rnkhdemo",
    "organizationId": "org_2x9rnkhdemo",
    "websiteId": "site_2x9rnkhdemo",
    "body": "We switched to a single guided setup step and activation improved. What changed onboarding for you?",
    "expectedRevision": 3,
    "mode": "audit",
    "opportunityId": "opp_2x9opportunity"
  }'

200400401402403404409422500

{
  "auditJobId": "job_2x9rnkhdemo",
  "kind": "audit_queued",
  "opportunityId": "opp_2x9opportunity"
}
{
  "error": {
    "code": "agentic_invalid_input",
    "message": "A comment can have up to 10,000 characters."
  }
}

Missing authentication

{
  "error": {
    "code": "agentic_unauthorized",
    "message": "Authenticate before using Rankhog agentic capabilities."
  }
}

Invalid API key

{
  "error": {
    "code": "agentic_paid_plan_required",
    "details": {
      "managedAccountBillingStatus": "active",
      "productId": "site_demo",
      "subscriptionStatus": "past_due"
    },
    "message": "This product has no active plan or trial yet. Call get_product_setup with productId site_demo: it gives the link where the person starts the 7-day trial. Never pay for them."
  }
}

Missing OAuth scope

{
  "error": {
    "code": "agentic_missing_scope",
    "details": {
      "missingScopes": [\
        "rankhog:read",\
        "reddit:draft:write"\
      ]
    },
    "message": "Missing required scope: rankhog:read, reddit:draft:write."
  }
}

API key organization mismatch

Organization access denied

Website access denied

Managed account not found

{
  "error": {
    "code": "agentic_managed_account_not_found",
    "message": "Managed Reddit account not found."
  }
}

Opportunity not found

{
  "error": {
    "code": "agentic_draft_conflict",
    "message": "The draft changed since revision 3. Reload and edit again."
  }
}
{
  "error": {
    "code": "agentic_draft_unsafe",
    "message": "This warm-up draft has not passed the helpfulness and repetition checks."
  }
}
{
  "error": {
    "code": "agentic_internal_error",
    "message": "Rankhog could not complete this agentic request."
  }
}

Cancel Opportunity ExecutionPOST\ \ Cancel one opportunity's pending execution and dismiss the opportunity. Audit Opportunity DraftPOST\ \ Audit a saved draft revision. Returns advisory findings without editing, approving, scheduling, or executing it.