Add relations to list when creating

Is there a sample for adding relations in API-3 and API-1/2?
I want to grant access to newly created list for users. API-3 does not do it by default.
My request looks like:
[httpMethod] => POST
[url] => https://1556191795.api-us1.com/api/3/lists
[bodyData] => {“list”:{“name”:“Name of List 2”,“stringid”:“Name-of-list-2”,“sender_url”:“http://activecampaign.com”,“sender_reminder”:“You are receiving this email as you subscribed to a newsletter when making an order on our site.”,“send_last_broadcast”:0,“carboncopy”:“”,“subscription_notify”:“”,“unsubscription_notify”:“”,“user”:1}}
)
The response is:

[list] => Array
(
[name] => Name of List 2
[stringid] => Name-of-list-2
[sender_url] => http://activecampaign.com
[sender_reminder] => You are receiving this email as you subscribed to a newsletter when making an order on our site.
[send_last_broadcast] => 0
[carboncopy] =>
[subscription_notify] =>
[unsubscription_notify] =>
[userid] => 1
[cdate] => 2019-05-09T05:17:05-05:00
[udate] => 2019-05-09T05:17:05-05:00
[links] => Array
(
[contactGoalLists] => https://1556191795.api-us1.com/api/3/lists/8/contactGoalLists
[user] => https://1556191795.api-us1.com/api/3/lists/8/user
[addressLists] => https://1556191795.api-us1.com/api/3/lists/8/addressLists
)

    [id] => 8
    [user] => 1
)

What does the request miss for granting access for a group to this list?

Thank you, Thomas

Hi there, Amy from ActiveCampaign’s Customer Experience Team. We’re just refreshing our forum page and I wanted to add some help here for anyone who comes across this page/question/post.

To grant access to a newly created list for users in ActiveCampaign API v3, you’ll need to use the “List Access” endpoint to add relations between the list and the users or user groups.

Here’s a guide on how to achieve this:

  1. Create the List: Use the /api/3/lists endpoint to create the list as you’ve already done.
  2. Retrieve User Group ID: You’ll need the ID of the user group to which you want to grant access to the list. You can retrieve this ID using the /api/3/userGroups endpoint.
  3. Grant Access: Use the /api/3/list/{listId}/userPermissions endpoint to grant access to the list for the user group. You’ll need to specify the list ID ({listId}) and the user group ID in the request body.

Here’s an example request:

http

Copy code

POST /api/3/list/8/userPermissions
Content-Type: application/json
Api-Token: YOUR_API_KEY

{
  "userPermissions": [
    {
      "userId": 1,  // ID of the user or user group to grant access
      "permission": "rw"  // Permission level: "rw" for read-write access, "r" for read-only access
    }
  ]
}

Replace YOUR_API_KEY, 8, and 1 with your actual API key, list ID, and user group ID, respectively.

In this example, the request grants read-write (rw) access to the list with ID 8 for the user group with ID 1. You can adjust the permission level as needed.

Any questions or additional ideas, thread them below!