Included relationships with same id and type

I want to send a response like that:

"data": [
        {
            "type": "participant",
            "id": "c15409",
            "attributes": {
                "licenseNumber": "",
                "givenName": "Valeria Alejandra",
                "familyName": "Snchez Arredondo",
                "passportGivenName": "VALERIA ALEJANDRA",
            },
            "relationships": {
                "organization": {
                    "data": {
                        "type": "organization",
                        "id": "1205"
                    }
                }
            }
        },
        {
            "type": "participant",
            "id": "c16733",
            "attributes": {
                "licenseNumber": "",
                "givenName": "Amir",
                "familyName": "Mota Castaeda",
                "passportGivenName": "AMIR",
            },
            "relationships": {
                "organization": {
                    "data": {
                        "type": "organization",
                        "id": "1205"
                    }
                }
            }
        },

"included": [
    {
        "type": "organization",
        "id": "1205",
        "attributes": {
             "name": "Team",
             "country": "USA"
         }
    },
{
        "type": "organization",
        "id": "1205",
        "attributes": {
             "name": "Team",
             "country": "USA"
         }
    },
]

Json:api doesn’t allow to have identical id and types, but I need that several participants can belong to the same team. How can do that?.
Is it right to do something like that?:

"data": [
        {
            "type": "participant",
            "id": "c15409",
            "attributes": {
                "licenseNumber": "",
                "givenName": "Valeria Alejandra",
                "familyName": "Snchez Arredondo",
                "passportGivenName": "VALERIA ALEJANDRA",
            },
            "relationships": {
                "organization": {
                    "data": {
                        "type": "organization",
                        "id": "1205"
                    }
                }
            }
        },
        {
            "type": "participant",
            "id": "c16733",
            "attributes": {
                "licenseNumber": "",
                "givenName": "Amir",
                "familyName": "Mota Castaeda",
                "passportGivenName": "AMIR",
            },
            "relationships": {
                "organization": {
                    "data": {
                        "type": "organization",
                        "id": "1205"
                    }
                }
            }
        },

"included": [
    {
        "type": "organization",
        "id": "1205",
        "attributes": {
             "name": "Team",
             "country": "USA"
         }
    }
]

Yes, even if multiple primary resources have a relationship to the same resource, that related resource only needs to be in included once.

1 Like