Last updated

Quickstart: Structured Data Memory

Import structured application data into Papr as an explicit knowledge graph.

Common pattern: extract rows from Postgres (customers, accounts, opportunities, orders), then map each row to graph nodes and relationships using memory_policy.mode = manual.

What You Will Build

  • Add graph nodes and relationships from structured records
  • Query those entities through memory search and graph analytics

Prerequisites

  • PAPR_MEMORY_API_KEY configured in your environment
  • Structured entities and relationships ready to map into memory_policy

Minimal Setup

  1. Write one memory payload in memory_policy.mode = manual.
  2. Search for related context with graph expansion enabled.
  3. Run a GraphQL query to verify entity persistence.

Example Source: Postgres -> Knowledge Graph

For example, if you have Postgres tables like accounts and opportunities:

  • Map each accounts row to an Account node.
  • Map each opportunities row to an Opportunity node.
  • Add a HAS_OPPORTUNITY relationship from account to opportunity.

That pattern is what the payload below demonstrates.

1) Add Structured Data with Manual Policy

curl -X POST https://memory.papr.ai/v1/memory \
  -H "X-API-Key: $PAPR_MEMORY_API_KEY" \
  -H "Content-Type: application/json" \
  -H "X-Client-Type: curl" \
  -d '{
    "content": "CRM import for account acme_001 and opportunity opp_778",
    "external_user_id": "ops_admin_01",
    "organization_id": "org_demo",
    "memory_policy": {
      "mode": "manual",
      "nodes": [
        {
          "id": "account_acme_001",
          "type": "Account",
          "properties": {"name": "Acme Corp", "segment": "enterprise"}
        },
        {
          "id": "opportunity_778",
          "type": "Opportunity",
          "properties": {"stage": "proposal", "amount": 120000}
        }
      ],
      "relationships": [
        {
          "source": "account_acme_001",
          "target": "opportunity_778",
          "type": "HAS_OPPORTUNITY"
        }
      ]
    }
  }'
curl -X POST "https://memory.papr.ai/v1/memory/search?max_memories=20&max_nodes=15" \
  -H "X-API-Key: $PAPR_MEMORY_API_KEY" \
  -H "Content-Type: application/json" \
  -H "X-Client-Type: curl" \
  -d '{
    "query": "Show opportunities related to Acme Corp and their current stage.",
    "organization_id": "org_demo",
    "enable_agentic_graph": true
  }'

3) Optional: Run GraphQL Analytics

curl -X POST https://memory.papr.ai/v1/graphql \
  -H "X-API-Key: $PAPR_MEMORY_API_KEY" \
  -H "Content-Type: application/json" \
  -H "X-Client-Type: curl" \
  -d '{
    "query": "query { nodes(type: \"Opportunity\") { id properties } }"
  }'

Validation Checklist

  • Manual write succeeds with nodes and relationships.
  • Search returns related structured entities.
  • GraphQL query returns expected node properties.

Troubleshooting

If relationships are missing, verify node IDs and relationship source/target values in your memory_policy payload.

Next Steps