# Get a company's timeline

`GET /v4/records/companies/{id}/timeline`

Notes, comments, logged communications, emails and todos on one company, newest first, in one list. Each item has `type`, `at` and `data`, which is exactly what the type's own list route returns. Requires `companies:read`; a hidden record is 404.

`types` (comma-separated: notes, comments, communications, emails, todos) defaults to every type the credential can read; the others are listed in `skipped` with reason `scope`. A type named in `types` without its scope is a 403. Emails follow the usual rule: a signed-in user's token sees only their own mailbox.

`at` is the creation time for notes, comments, communications (their `date` is a calendar day) and todos, and the sent time for emails. `limit` is 1-50 (default 20). Pass `next_before` back as `before` for the next page; it is null on the last page. `since` (RFC 3339 with offset) keeps items at or after that time.

Authentication (security requirement alternatives):

```json
[
  {
    "bearer_auth": [
      "companies:read"
    ]
  },
  {
    "oauth2_auth": [
      "companies:read"
    ]
  },
  {
    "apikey_auth": [
      "companies:read"
    ]
  }
]
```

- bearer_auth: http (bearer). API key or OAuth access token in Authorization header; scopes: companies:read
- oauth2_auth: oauth2. OAuth authorization code flow with mandatory S256 PKCE.; scopes: companies:read
- apikey_auth: apiKey, query api_key. API key in query string; scopes: companies:read

Parameters:

- `id` (path, string, required) - Record ID
  Type: string

- `types` (query, string, optional) - Comma-separated: notes, comments, communications, emails, todos
  Type: string

- `limit` (query, integer, optional) - 1-50, default 20
  Type: integer

- `before` (query, string, optional) - next_before from the previous page
  Type: string

- `since` (query, string, optional) - RFC 3339 with offset
  Type: string

Responses:

- 200: Timeline

Content type: application/json

Type: object

Schema: [RecordTimelineResponse](https://docs.searchsoftware.nl/api/models/recordtimelineresponse.md)

- `status` (required)
  Type: string
  
  Example:
  
  ```json
  "ok"
  ```

- `data` (required)
  Reference: [RecordTimelineData](https://docs.searchsoftware.nl/api/models/recordtimelinedata.md); Type: object

- 401: Invalid API key

Content type: application/json

Type: unknown

Example:

```json
{
  "status": "error",
  "error": {
    "code": "INVALID_API_KEY",
    "status_code": 401,
    "message": "Invalid API key"
  }
}
```

allOf:
  Reference: [ErrorResponse](https://docs.searchsoftware.nl/api/models/errorresponse.md); Type: object

```json
{
  "status": "error",
  "error": {
    "code": "INVALID_API_KEY",
    "status_code": 401,
    "message": "Invalid API key"
  }
}
```

- 403: Insufficient scope

Content type: application/json

Type: unknown

Example:

```json
{
  "status": "error",
  "error": {
    "code": "FORBIDDEN",
    "status_code": 403,
    "message": "Insufficient scope"
  }
}
```

allOf:
  Reference: [ErrorResponse](https://docs.searchsoftware.nl/api/models/errorresponse.md); Type: object

```json
{
  "status": "error",
  "error": {
    "code": "FORBIDDEN",
    "status_code": 403,
    "message": "Insufficient scope"
  }
}
```

- 404: Record not found

Content type: application/json

Type: unknown

Example:

```json
{
  "status": "error",
  "error": {
    "code": "NOT_FOUND",
    "status_code": 404,
    "message": "Record not found"
  }
}
```

allOf:
  Reference: [ErrorResponse](https://docs.searchsoftware.nl/api/models/errorresponse.md); Type: object

```json
{
  "status": "error",
  "error": {
    "code": "NOT_FOUND",
    "status_code": 404,
    "message": "Record not found"
  }
}
```

- 422: Invalid parameters

Content type: application/json

Type: unknown

Example:

```json
{
  "status": "error",
  "error": {
    "code": "VALIDATION_FAILED",
    "status_code": 422,
    "message": "Validation failed"
  }
}
```

allOf:
  Reference: [ErrorResponse](https://docs.searchsoftware.nl/api/models/errorresponse.md); Type: object

```json
{
  "status": "error",
  "error": {
    "code": "VALIDATION_FAILED",
    "status_code": 422,
    "message": "Validation failed"
  }
}
```

- 500: Internal server error

Content type: application/json

Type: unknown

Example:

```json
{
  "status": "error",
  "error": {
    "code": "INTERNAL_ERROR",
    "status_code": 500,
    "message": "Internal server error"
  }
}
```

allOf:
  Reference: [ErrorResponse](https://docs.searchsoftware.nl/api/models/errorresponse.md); Type: object

```json
{
  "status": "error",
  "error": {
    "code": "INTERNAL_ERROR",
    "status_code": 500,
    "message": "Internal server error"
  }
}
```

## Examples

### cURL

```bash
curl -X GET 'https://api.searchsoftware.nl/v4/records/companies/string/timeline' \
  -H 'Authorization: Bearer YOUR_TOKEN'
```

### TypeScript

```typescript
const response = await fetch('https://api.searchsoftware.nl/v4/records/companies/string/timeline', {
  method: 'GET',
  headers: {
    'Authorization': 'Bearer YOUR_TOKEN',
  },
});

const data = await response.text();
```

### Python

```python
import requests

response = requests.get(
    'https://api.searchsoftware.nl/v4/records/companies/string/timeline',
    headers={
        'Authorization': 'Bearer YOUR_TOKEN',
    },
)
print(response.text)
```

### Ruby

```ruby
require 'net/http'
require 'json'

uri = URI('https://api.searchsoftware.nl/v4/records/companies/string/timeline')
request = Net::HTTP::Get.new(uri)
request['Authorization'] = 'Bearer YOUR_TOKEN'

response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: uri.scheme == 'https') { |http| http.request(request) }
data = JSON.parse(response.body)
```

### Go

```go
package main

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

func main() {
  req, _ := http.NewRequest("GET", "https://api.searchsoftware.nl/v4/records/companies/string/timeline", nil)
  req.Header.Set("Authorization", "Bearer YOUR_TOKEN")
  resp, _ := http.DefaultClient.Do(req)
  defer resp.Body.Close()
  data, _ := io.ReadAll(resp.Body)
  fmt.Println(string(data))
}
```

### PHP

```php
<?php
$ch = curl_init('https://api.searchsoftware.nl/v4/records/companies/string/timeline');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, ['Authorization: Bearer YOUR_TOKEN']);

$response = curl_exec($ch);
curl_close($ch);
$data = json_decode($response, true);
```

### Rust

```rust
use reqwest;

#[tokio::main]
async fn main() -> Result<(), reqwest::Error> {
    let client = reqwest::Client::new();
    let response = client.get("https://api.searchsoftware.nl/v4/records/companies/string/timeline")
        .header("Authorization", "Bearer YOUR_TOKEN")
        .send()
        .await?
        .text()
        .await?;
    println!("{}", response);
    Ok(())
}
```
