ONE social:attribution
← Receivers

social:attribution

social family

mcp

Revenue per post. For one workspace over a date range, per variant, post, network and campaign: tracked-link clicks (and distinct clickers), hosted-page visits, leads, booked jobs, sales and revenue that came from each post's tracked link (utm_medium=social, utm_content = the variant id). Revenue is one figure per currency, never added across currencies, net of refunds so far; test money, unrecorded money and ONE's own money are left out and counted in reads.orders. Organic and paid are two columns: paid is ad-medium leads and sales per campaign that holds these posts (every ad network), with spend read from the ads tables (lifetime to date) and a cost per lead only when spend is one currency. A booked job's value has no currency on record and is never added to revenue. Each count says what it read; `truncated` names any read that stopped at 5000 rows. A sale or booked job found on a variant marks that variant's paths once — the same edges engagement marks (network → format, hour, hook) — and a refund takes back its share.

Effect
ask
Awaits an outcome — the call returns the response below.
Caller
read_corpus
The class of authority the caller must already hold, decided from the attested context with no round trip.
Cost
free
What one call costs, so you can budget before acting.
Reversible
yes
The effect can be undone by a later call.
Idempotent
yes
Safe to retry as-is.

Send it with your agent

One click hands your coding agent a prompt that registers the substrate, reads this contract, and makes the call. Launch opens the app; the others copy the prompt.

Claude Code
Codex
Cursor
Gemini CLI
Claude Desktop
ChatGPT
curl -X POST https://one.ie/api/ask/social:attribution \
  -H "Authorization: Bearer $ONE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"data": { "workspace": <string>, "from": <number>, "to": <number>, "network": <string> }}'

The key is never in a link. npx -y @oneie/cli login writes it to ~/.config/oneie/key on your machine.

Request

Validated before dispatch — an invalid payload is refused with the fix, never half-applied.

  • workspace string optional Defaults to the caller's own. Another workspace needs its owner, an admin or the agency above (a D1 walk), never the body alone.
  • from number optional Epoch ms. Default 30 days before `to`.
  • to number optional Epoch ms. Default now. At most 366 days after `from`.
  • network string optional One network only (facebook, instagram, linkedin, …).
  • campaign string optional One campaign only (a campaign group id).
  • postId string optional One post only (the master post id).

Response

What comes back from the call.

  • ok boolean
  • error string unauthenticated · no_db · bad_workspace · forbidden: … · bad_range: … · read_failed: …
  • workspace string
  • range object
  • organic object
  • paid object
  • reads object Rows read per source; orders: read, counted, testExcluded, unrecorded, oursExcluded, refunded, notPaid, unattributed.
  • truncated string[] The reads that stopped at 5000 rows: those counts are short.
  • notes string[]
  • settled object Paths marked for newly found sales and booked jobs, and weight taken back for refunds, on this call.

Traffic

Every call to social:attribution, counted where it is dispatched — over HTTP or in-process alike. Aggregate only — no actor, no payload, no workspace.

Counting…

Wiring

Every place in the open source that names social:attribution, and the file that answers it. Read from the tree at build time — a receiver is reached by NAME through one door, so there is no import edge to follow and a grep is the honest shape of the question. Structure, not volume — the count is in Traffic above.

Called from

API route 2
  • one.ie/web/src/lib/receiver-index.generated.ts:450
  • one.ie/web/src/lib/resolvers/social-analytics.ts:69
CLI 1
  • packages/cli/src/social.ts:488
SDK 1
  • packages/sdk/src/social.ts:56
→
JSON Schema
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "workspace": {
      "description": "Defaults to the caller's own. Another workspace needs its owner, an admin or the agency above (a D1 walk), never the body alone.",
      "type": "string"
    },
    "from": {
      "description": "Epoch ms. Default 30 days before `to`.",
      "type": "number"
    },
    "to": {
      "description": "Epoch ms. Default now. At most 366 days after `from`.",
      "type": "number"
    },
    "network": {
      "description": "One network only (facebook, instagram, linkedin, …).",
      "type": "string"
    },
    "campaign": {
      "description": "One campaign only (a campaign group id).",
      "type": "string"
    },
    "postId": {
      "description": "One post only (the master post id).",
      "type": "string"
    }
  }
}
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "ok": {
      "type": "boolean"
    },
    "error": {
      "description": "unauthenticated · no_db · bad_workspace · forbidden: … · bad_range: … · read_failed: …",
      "type": "string"
    },
    "workspace": {
      "type": "string"
    },
    "range": {
      "type": "object",
      "properties": {
        "from": {
          "type": "number"
        },
        "to": {
          "type": "number"
        }
      },
      "required": [
        "from",
        "to"
      ]
    },
    "organic": {
      "type": "object",
      "properties": {
        "byVariant": {
          "type": "array",
          "items": {
            "type": "object",
            "propertyNames": {
              "type": "string"
            },
            "additionalProperties": {}
          },
          "description": "variantId (null for a post with no variants), postId, network, format, campaign, publishedAt (unix s), hook, clicks, people, visits, leads, booked, bookedValueCents, sales, revenue [{currency, cents}], dmLeads, dmSales (null = no Meta DM event recorded)."
        },
        "byPost": {
          "type": "array",
          "items": {
            "type": "object",
            "propertyNames": {
              "type": "string"
            },
            "additionalProperties": {}
          }
        },
        "byNetwork": {
          "type": "array",
          "items": {
            "type": "object",
            "propertyNames": {
              "type": "string"
            },
            "additionalProperties": {}
          }
        },
        "byCampaign": {
          "type": "array",
          "items": {
            "type": "object",
            "propertyNames": {
              "type": "string"
            },
            "additionalProperties": {}
          }
        },
        "totals": {
          "type": "object",
          "propertyNames": {
            "type": "string"
          },
          "additionalProperties": {}
        }
      },
      "required": [
        "byVariant",
        "byPost",
        "byNetwork",
        "byCampaign",
        "totals"
      ]
    },
    "paid": {
      "type": "object",
      "properties": {
        "byCampaign": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "campaign": {
                "type": "string"
              },
              "spend": {
                "anyOf": [
                  {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "currency": {
                          "type": "string"
                        },
                        "cents": {
                          "type": "number"
                        }
                      },
                      "required": [
                        "currency",
                        "cents"
                      ]
                    }
                  },
                  {
                    "type": "null"
                  }
                ],
                "description": "Lifetime to date; null when no ad of the campaign was ever read."
              },
              "spendReadAt": {
                "anyOf": [
                  {
                    "type": "number"
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "unreadAds": {
                "type": "number"
              },
              "leads": {
                "type": "number"
              },
              "booked": {
                "type": "number"
              },
              "sales": {
                "type": "number"
              },
              "revenue": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "currency": {
                      "type": "string"
                    },
                    "cents": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "currency",
                    "cents"
                  ]
                }
              },
              "costPerLead": {
                "anyOf": [
                  {
                    "type": "object",
                    "properties": {
                      "currency": {
                        "type": "string"
                      },
                      "cents": {
                        "type": "number"
                      }
                    },
                    "required": [
                      "currency",
                      "cents"
                    ]
                  },
                  {
                    "type": "null"
                  }
                ],
                "description": "Only when spend is one currency and there is a lead."
              }
            },
            "required": [
              "campaign",
              "spend",
              "spendReadAt",
              "unreadAds",
              "leads",
              "booked",
              "sales",
              "revenue",
              "costPerLead"
            ]
          }
        }
      },
      "required": [
        "byCampaign"
      ]
    },
    "reads": {
      "description": "Rows read per source; orders: read, counted, testExcluded, unrecorded, oursExcluded, refunded, notPaid, unattributed.",
      "type": "object",
      "propertyNames": {
        "type": "string"
      },
      "additionalProperties": {}
    },
    "truncated": {
      "description": "The reads that stopped at 5000 rows: those counts are short.",
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "notes": {
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "settled": {
      "description": "Paths marked for newly found sales and booked jobs, and weight taken back for refunds, on this call.",
      "type": "object",
      "properties": {
        "marked": {
          "type": "number"
        },
        "warned": {
          "type": "number"
        }
      },
      "required": [
        "marked",
        "warned"
      ]
    }
  },
  "required": [
    "ok"
  ]
}