Not sure I understand all the 'Id' keys. Help, please!

Here is a json describing a basic card ‘Test API (Drafts)’, which is a child of a Drafts card. Another card have a link to ‘Test API (Drafts)’. There are too many Id keys in this json and I’m not sure I understand all of them. Can you please, help me understand these (I marked them with comments):

[
  {
    "id": "2bd6ef45-60d7-42ad-90d0-55d7145c3627",
    // is this some kind of request ID and can be random when creating new card?
    "card": {
      "id": "3fd38821-0cf8-4abc-8051-fd50e22ae7c7",
      // card ID, I understand this. So, I should generate uuid to create a new card?
      "name": "Test API (Drafts)",
      "markup": "Body text",
      "html": "<p>Body text</p>\n",
      "icon": null,
      "owner_id": "b2067d38-113c-46ee-9473-71c79f90bfd9",
      // My user ID. No issues here.
      "share_code": "brick february chase power",
      "frozen": null,
      "created_when": "2020-07-03T11:21:44.883000",
      "modified_when": "2020-07-03T11:22:30.666376",
      "synced_when": "2020-07-03T11:22:30.666376",
      "status": 2,
      "default_perms": 25230431,
      "backlinks": [
        {
          "back_id": "88ffe1a6-1f33-451f-a7b9-1006c4f12095",
          // this is a link to the card, which links to our card
          "fore_id": "3fd38821-0cf8-4abc-8051-fd50e22ae7c7",
         // our card ID (which link was used)
          "created_when": "2020-07-03T11:23:31.280729"
        }
      ],
      "tags": [],
      "member_count": 1,
      "likes": 0,
      "comment_count": 0,
      "published_child_count": 0
    },
    "perms": 67108863,
    "color": null,
    "liked": null,
    "created_when": "2020-07-03T11:21:44.883000",
    "modified_when": "2020-07-03T11:22:05.723756",
    "visited_when": "2020-07-03T11:22:05.723762",
    "status": 2,
    "enrolled": true,
    "personal_tags": [],
    "parent_links": [
      {
        "base": {
          "id": "3ce2b395-f553-479c-b207-aeb13d0109c8",
          // not sure what this means. Another random ID?
          "owner_id": "b2067d38-113c-46ee-9473-71c79f90bfd9",
          // card owner ID (my ID).
          "parent_card_id": "8d574da9-35a5-45bc-9a23-86c802cb0f74",
          // parent card ID (Drafts)
          "child_card_id": "3fd38821-0cf8-4abc-8051-fd50e22ae7c7",
          // link to itself? Why? Don't understand this...
          "primary": true,
          "published": true,
          "default_perms": -1,
          "created_when": "2020-07-03T11:22:05.728946",
          "modified_when": null
        },
        "parent_id": "ed885cc4-a203-486c-bba1-b41ded664d39",
        // not sure what it is... Any hints?
        "hidden": false,
        "status": 2
      }
    ],
    "is_context": false,
    "has_commented": false,
    "held_published_child_count": 0,
    "held_total_child_count": 0
  }
]

Thanks in advance!

Looks like id and parent_links > base > id can hold the same value like card > id.

So the first thing is that practically everything on the platform uses UUIDs, so that you can create objects locally (/ while offline) which are guaranteed not to clash with existing objects.

Here is a brief summary of the IDs you’re looking at, which I’ll explain in the order they appear:

  1. CardMembership.id: The root object is your card membership, that relates your user account to a particular card.
  2. Card.id: Cards do need UUIDs as well, but the backend will create one for you if you do not provide one.
  3. User.id: Yep your user ID. As with many things, doesn’t need to be provided in a creation request – this is enforced by the backend.
  4. Bi-directional links point towards Card.ids.
  5. “parent_links” this is the Supernotes nesting structure, and will soon be renamed just “parents” now that we have “backlinks” as well. Parent relationships are comprised of two things: the Base, which is data that is universal to all users who can see that think, and the MembershipLink, which links two CardMemberships together. The first ID is the Base, which get referenced by MembershipLinkss. parent_card_id and child_card_id are fairly self explanatory. Then the parent_id is the ID to the parent CardMembership, which is the first ID explained.

Hope that helps.

Thanks a lot for such a great explanation. Your answer solves all my id-related issues.
Thanks one again!

{
  "id": "c4936cc5-326a-4761-8a97-cb5eb3b4bed9",
  "card": {
    "name": "Reading6",
    "id": "8f66677a-2f4a-411d-9ff0-48f5ae8d8159"  
  },
  "parent_links": [
    {
      "base": {
        "id": "219b3c37-8292-4dde-b42f-522ec555cf1a",
        "parent_card_id": "8d574da9-35a5-45bc-9a23-86c802cb0f74",
        "primary": true,
        "published": true
      }
    }
  ]
}

Something wrong here. Server gives me an error if I omit the '“id”: “8f66677a-2f4a-411d-9ff0-48f5ae8d8159” (or leave it empty/null):

{
  "errors": {
    "id": "field required"
  }
}

Just had a double check and you are correct: I’ve made Card.id required when creating a new card.

Just generate a UUIDv4 when you want to create a new card.