# Retrieving more than 1000 users through import-export extension jobs

**URL:** <https://community.auth0.com/t/retrieving-more-than-1000-users-through-import-export-extension-jobs/103656>\
**Category:** Get Help\
**Tags:** users, management-api\
**Created:** [March 29, 2023, 3:29pm UTC](https://community.auth0.com/t/retrieving-more-than-1000-users-through-import-export-extension-jobs/103656 "2023-03-29T15:29:54Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![nicolas.tudor](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/nicolas.tudor/32/45886_2.png) [@nicolas.tudor](https://community.auth0.com/u/nicolas.tudor)\
**Post date:** [March 29, 2023, 3:29pm UTC](https://community.auth0.com/t/retrieving-more-than-1000-users-through-import-export-extension-jobs/103656/1 "2023-03-29T15:29:54Z")

</div>

Hello there,

I’m using pagination to retrieve users for my backend at the endpoint /api/v2/users, which is working well. However, I have reached the limit of 1000 users, which is the maximum number of users this method/endpoint can retrieve.

To overcome this limitation, I’ve attempted to use the import-export extension jobs offered by Auth0, but I only get the following response: {“statusCode”:404,“error”:“Not Found”,“message”:“Not Found”}

I’m sharing a code snippet of the curl request that I’m using:

$curl = curl\_init();  
curl\_setopt\_array($curl, array(  
CURLOPT\_URL =\> “[https://yadayada.eu.auth0.com/api/v2/jobs/user-exports”](https://yadayada.eu.auth0.com/api/v2/jobs/user-exports%E2%80%9D),  
CURLOPT\_RETURNTRANSFER =\> true,  
CURLOPT\_ENCODING =\> “”,  
CURLOPT\_MAXREDIRS =\> 10,  
CURLOPT\_TIMEOUT =\> 30,  
CURLOPT\_HTTP\_VERSION =\> CURL\_HTTP\_VERSION\_1\_1,  
CURLOPT\_CUSTOMREQUEST =\> “POST”,  
CURLOPT\_POSTFIELDS =\> “{“format”: “json”, “export\_as”: “provider” }”,  
CURLOPT\_HTTPHEADER =\> array(  
"authorization: Bearer ".$token,  
“cache-control: application/json”  
),  
));

$response = curl\_exec($curl);

If anyone has any advice or can offer any help, it would be much appreciated. Thank you!

---

<div class="post-metadata">

**Author:** ![gparascandolo](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/gparascandolo/32/38788_2.png) [@gparascandolo](https://community.auth0.com/u/gparascandolo)\
**Post date:** [March 29, 2023, 4:03pm UTC](https://community.auth0.com/t/retrieving-more-than-1000-users-through-import-export-extension-jobs/103656/2 "2023-03-29T16:03:27Z")

</div>

Hi @nicolas.tudor , it looks like you made a small typo on the Management API endpoint for the request

Your curl request is pointing to `/api/v2/jobs/user-exports`, instead of the correct `/api/v2/jobs/users-exports` [endpoint](https://auth0.com/docs/api/management/v2#!/Jobs/post_users_exports)

Hope this helps!

---

<div class="post-metadata">

**Author:** ![nicolas.tudor](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/nicolas.tudor/32/45886_2.png) [@nicolas.tudor](https://community.auth0.com/u/nicolas.tudor)\
**Post date:** [March 30, 2023, 11:15am UTC](https://community.auth0.com/t/retrieving-more-than-1000-users-through-import-export-extension-jobs/103656/3 "2023-03-30T11:15:27Z")

</div>

Hi @gparascandolo that was indeed a silly typo thank you for pointing it out.  
Now that the job is exported, I wrote a function that takes the jobId of the previous request. The current response has a location field, which points to an AWS url to download the users from the exported job, I thought I was done when I realised that only 4 users were retrieved out of the 1050, the response looks like json wrapped in a string, and since it’s incomplete I cannot use json\_decode() on it.

This is my userImport function:

function userImport($token, $jobId){

```
	$curl = curl_init();

$status = "pending";

$loops = 0;

while($status != "completed"){

curl_setopt_array($curl, array(
CURLOPT_URL => "https://yadayada/api/v2/jobs/".$jobId."",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => array(
    "authorization: Bearer ".$token,
    "cache-control: no-cache"
),

```

));

$response = curl\_exec($curl);  
$err = curl\_error($curl);

$data = json\_decode($response);

$status = $data-\>status;

if($status == “completed”){  
$location = $data-\>location;  
$compressedUsers = file\_get\_contents($location);  
$decompressedUsers = gzdecode($compressedUsers); //returns 4 users in a string  
$jsonUsers = json\_decode($decompressedUsers); //returns null because decompressedUsers is most likely incomplete.

```
return $jsonUsers;

```

}

if ($err) {  
echo “cURL Error #:” . $err;  
break;  
} else {  
echo $response;  
}

```
if($loops > 2){
	break;
}

sleep(20);

$loops++;

}

```

curl\_close($curl);

```
}

```

Apologies for asking again, but would you be able to tell me if I’m missing something here?

---

<div class="post-metadata">

**Author:** ![gparascandolo](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/gparascandolo/32/38788_2.png) [@gparascandolo](https://community.auth0.com/u/gparascandolo)\
**Post date:** [March 30, 2023, 3:24pm UTC](https://community.auth0.com/t/retrieving-more-than-1000-users-through-import-export-extension-jobs/103656/4 "2023-03-30T15:24:09Z")

</div>

Based on what I can see in the initial code snippet, I _believe_ the POST fields you are putting in the request might be causing an issue

Try simply passing in `{"format": "json"}` in the POST fields and try again.

In case you’ve made modifications to the request from your initial post, make sure you are not passing in `connection_id` or `limit` params either.

If all else fails, you can try installing and using the [User Import / Export Extension](https://auth0.com/docs/customize/extensions/user-import-export-extension#install-the-extension) in your tenant to export all your users.

I hope this helps!

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [April 13, 2023, 3:24pm UTC](https://community.auth0.com/t/retrieving-more-than-1000-users-through-import-export-extension-jobs/103656/5 "2023-04-13T15:24:54Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
