> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.warelycorp.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.warelycorp.com/_mcp/server.

# Issue SP Access Token

POST https://dev.warelypos.com/api/sp/auth/token

Issues a short-lived SP Digital access token for the calling integration.

Example curl:

```bash
curl --request POST '{{base_url}}/sp/auth/token' \
  --header 'Content-Type: application/json' \
  --data-raw '{
    "client_id": "{{client_id}}",
    "client_secret": "{{client_secret}}"
  }'

```

Example success response shape:

```json
{
  "success": true,
  "message": "SP access token issued successfully.",
  "data": {
    "access_token": "<bearer-token>",
    "token_type": "Bearer",
    "expires_in": 7200,
    "expires_at": "2026-04-06 14:30:00",
    "scope": "wa.members.read wa.members.write wa.wallet.read",
    "business_id": 2,
    "integration_id": 1
  },
  "meta": {}
}

```

Example error response shape:

```json
{
  "success": false,
  "message": "The provided SP client credentials are invalid.",
  "error": {
    "code": "invalid_client_credentials",
    "details": {}
  }
}

```

Notes:

* Access tokens expire after 2 hours.

* No refresh token is issued in this flow. When the token expires, call this endpoint again with the same `client_id` and `client_secret`.

Reference: https://docs.warelycorp.com/api-reference/auth/issue-sp-access-token

## Authentication

- `Authorization` header (bearer token, required) — Bearer authentication of the form `Bearer <token>`, where token is your auth token.

## Response

### 200

200 OK Example

- `success` (boolean, optional)
- `message` (string, optional)
- `data` (SpAuthTokenPostResponsesContentApplicationJsonSchemaData, optional)
- `meta` (SpAuthTokenPostResponsesContentApplicationJsonSchemaMeta, optional)

## Types

### SpAuthTokenPostResponsesContentApplicationJsonSchemaData

- `access_token` (string, optional)
- `token_type` (string, optional)
- `expires_in` (integer, optional)
- `expires_at` (string, optional)
- `scope` (string, optional)
- `business_id` (integer, optional)
- `integration_id` (integer, optional)

### SpAuthTokenPostResponsesContentApplicationJsonSchemaMeta

## Examples

**Response**

```json
{
  "success": true,
  "message": "SP access token issued successfully.",
  "data": {
    "access_token": "<bearer-token>",
    "token_type": "Bearer",
    "expires_in": 7200,
    "expires_at": "2026-04-06 14:30:00",
    "scope": "wa.members.read wa.members.write wa.wallet.read",
    "business_id": 2,
    "integration_id": 1
  },
  "meta": {}
}
```

**SDK Code**

```python Auth_issueSpAccessToken_example
import requests

url = "https://dev.warelypos.com/api/sp/auth/token"

headers = {"Authorization": "Bearer <token>"}

response = requests.post(url, headers=headers)

print(response.json())
```

```javascript Auth_issueSpAccessToken_example
const url = 'https://dev.warelypos.com/api/sp/auth/token';
const options = {method: 'POST', headers: {Authorization: 'Bearer <token>'}};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go Auth_issueSpAccessToken_example
package main

import (
	"fmt"
	"net/http"
	"io"
)

func main() {

	url := "https://dev.warelypos.com/api/sp/auth/token"

	req, _ := http.NewRequest("POST", url, nil)

	req.Header.Add("Authorization", "Bearer <token>")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby Auth_issueSpAccessToken_example
require 'uri'
require 'net/http'

url = URI("https://dev.warelypos.com/api/sp/auth/token")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'

response = http.request(request)
puts response.read_body
```

```java Auth_issueSpAccessToken_example
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://dev.warelypos.com/api/sp/auth/token")
  .header("Authorization", "Bearer <token>")
  .asString();
```

```php Auth_issueSpAccessToken_example
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://dev.warelypos.com/api/sp/auth/token', [
  'headers' => [
    'Authorization' => 'Bearer <token>',
  ],
]);

echo $response->getBody();
```

```csharp Auth_issueSpAccessToken_example
using RestSharp;

var client = new RestClient("https://dev.warelypos.com/api/sp/auth/token");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
IRestResponse response = client.Execute(request);
```

```swift Auth_issueSpAccessToken_example
import Foundation

let headers = ["Authorization": "Bearer <token>"]

let request = NSMutableURLRequest(url: NSURL(string: "https://dev.warelypos.com/api/sp/auth/token")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```