# Create Store Cannel AccessKey Over API

**URL:** <https://forum.shopware.com/t/create-store-cannel-accesskey-over-api/101935>\
**Category:** Programming (EN)\
**Created:** [16. November 2023 um 07:17 UTC](https://forum.shopware.com/t/create-store-cannel-accesskey-over-api/101935 "2023-11-16T07:17:42Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![klas](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.shopware.com/klas/32/22232_2.png) [@klas](https://forum.shopware.com/u/klas)\
**Post date:** [16. November 2023 um 07:17 UTC](https://forum.shopware.com/t/create-store-cannel-accesskey-over-api/101935/1 "2023-11-16T07:17:42Z")

</div>

Hi,

Im creating a store-channel through Shopware API (/api/sales-channel) and Accesskey is required  
„accessKey“: „\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*“,  
I can put a random value as accessKey and the sales channel is created but the Accesskey isn’t valid for use.  
How to generate a valid Accesskey through the API?

---

<div class="post-metadata">

**Author:** ![Max\_Shop](https://avatars.discourse-cdn.com/v4/letter/m/58f4c7/32.png) [@Max\_Shop](https://forum.shopware.com/u/Max_Shop)\
**Post date:** [16. November 2023 um 09:23 UTC](https://forum.shopware.com/t/create-store-cannel-accesskey-over-api/101935/2 "2023-11-16T09:23:41Z")

</div>

> <https://github.com/shopware/shopware/blob/242c0e4e0b4cea4fe0d774db281a595584a2441e/src/Core/Framework/Api/Util/AccessKeyHelper.php#L27>

---

<div class="post-metadata">

**Author:** ![klas](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.shopware.com/klas/32/22232_2.png) [@klas](https://forum.shopware.com/u/klas)\
**Post date:** [16. November 2023 um 09:39 UTC](https://forum.shopware.com/t/create-store-cannel-accesskey-over-api/101935/3 "2023-11-16T09:39:33Z")

</div>

Thanx for the answer but how should the API request look?  
And witch Url to POST to?

---

<div class="post-metadata">

**Author:** ![Max\_Shop](https://avatars.discourse-cdn.com/v4/letter/m/58f4c7/32.png) [@Max\_Shop](https://forum.shopware.com/u/Max_Shop)\
**Post date:** [16. November 2023 um 09:49 UTC](https://forum.shopware.com/t/create-store-cannel-accesskey-over-api/101935/4 "2023-11-16T09:49:39Z")

</div>

> [@Max\_Shop](#):
>
> `function generateAccessKey(string $identifier)`

this function generates you a valid AccessKey, It must be a base65 encoded 16 chars long alphanumeric string.

Then you should be able to use it in your example.

---

<div class="post-metadata">

**Author:** ![klas](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.shopware.com/klas/32/22232_2.png) [@klas](https://forum.shopware.com/u/klas)\
**Post date:** [16. November 2023 um 10:11 UTC](https://forum.shopware.com/t/create-store-cannel-accesskey-over-api/101935/5 "2023-11-16T10:11:28Z")

</div>

But i need to create the AccessKey outside of Shopware, Using Laravel to set up a sales channel,  
And a random base65 encoded 16 chars long alphanumeric string generates error: ‚Access key is invalid and could not be identified‘

---

<div class="post-metadata">

**Author:** ![klas](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.shopware.com/klas/32/22232_2.png) [@klas](https://forum.shopware.com/u/klas)\
**Post date:** [16. November 2023 um 11:41 UTC](https://forum.shopware.com/t/create-store-cannel-accesskey-over-api/101935/6 "2023-11-16T11:41:21Z")

</div>

Found the solution

Url: /api/\_action/access-key/sales-channel

```auto
$response = $client->get($url, [
    'headers' => [
        'Authorization' => 'Bearer ' . $accessToken,
    ],
]);

```

---

<div class="post-metadata">

**Author:** ![system](https://europe1.discourse-cdn.com/flex013/uploads/shopware/original/3X/2/9/29c7587ba660f00e4995d1743162782e5d6d8653.svg) [@system](https://forum.shopware.com/u/system)\
**Post date:** [16. Dezember 2023 um 11:41 UTC](https://forum.shopware.com/t/create-store-cannel-accesskey-over-api/101935/7 "2023-12-16T11:41:55Z")

</div>

Dieses Thema wurde automatisch 30 Tage nach der letzten Antwort geschlossen. Es sind keine neuen Antworten mehr erlaubt.
