API Documentation

Send logs, code snippets, and text directly from your command line to CopyAndPaste.at

Quick Start

tail -n 100 /var/log/auth.log | curl -X POST https://copyandpaste.at/api/log --data-binary @-

That's it! The response will be your paste URL that you can share immediately.

Pro Tip: Create an alias for even easier use:

alias paste='curl -X POST https://copyandpaste.at/api/log --data-binary @-'

Then simply: docker logs myapp | paste

Simple Log API

Endpoint

POST https://copyandpaste.at/api/log

Features

  • Accepts raw text data - no JSON formatting required
  • Auto-detects content type (logs, PHP, JavaScript, SQL, etc.)
  • Returns plain text URL for easy scripting
  • 30-day expiration

Examples

Send log files:

tail -n 50 /var/log/nginx/error.log | curl -X POST https://copyandpaste.at/api/log --data-binary @-

Send Docker container logs:

docker logs mycontainer | curl -X POST https://copyandpaste.at/api/log --data-binary @-

Send command output:

ps aux | curl -X POST https://copyandpaste.at/api/log --data-binary @-

Send file contents:

cat config.php | curl -X POST https://copyandpaste.at/api/log --data-binary @-

Full JSON API

Endpoint

POST https://copyandpaste.at/api/paste

When to use

Use the JSON API when you need to specify custom titles, languages, or when integrating with applications that need structured responses.

Request Format

curl -X POST https://copyandpaste.at/api/paste \
  -H "Content-Type: application/json" \
  -d '{
    "content": "Your content here",
    "title": "Custom Title",
    "language": "javascript"
  }'

Parameters

ParameterTypeRequiredDescription
contentstring✅ YesThe text content to paste
titlestring❌ NoCustom title (defaults to "Untitled")
languagestring❌ NoLanguage for syntax highlighting

Response

{
  "id": "abc1234567"
}

The paste will be available at: https://copyandpaste.at/abc1234567

Supported Languages

For syntax highlighting, you can specify any of these languages:

bashshelllogjsonyamlpythonjavascripttypescriptphpsqldockerfilenginxapachexmlhtmlcssjavagorustcppcrubyperltext

Useful Aliases & Functions

Basic Alias

Add to your ~/.bashrc or ~/.zshrc:

alias paste='curl -X POST https://copyandpaste.at/api/log --data-binary @-'

Advanced Function with URL Copy

pasteit() {
    local url=$(curl -s -X POST https://copyandpaste.at/api/log --data-binary @-)
    echo "Paste URL: $url"
    
    # Copy to clipboard (macOS)
    if command -v pbcopy >/dev/null 2>&1; then
        echo "$url" | pbcopy
        echo "URL copied to clipboard!"
    fi
    
    # Copy to clipboard (Linux)
    if command -v xclip >/dev/null 2>&1; then
        echo "$url" | xclip -selection clipboard
        echo "URL copied to clipboard!"
    fi
}

Best Practices

⚠️ Security

  • • Always review logs before sharing to ensure no sensitive data is included
  • • Avoid sending passwords, API keys, or personal information
  • • Remember that pastes are publicly accessible via their URLs

✅ Performance

  • • For large logs, use tail or head to limit size
  • • Consider using gzip for very large content
  • • All pastes expire automatically after 30 days

Integration Examples

Monitoring Scripts

#!/bin/bash
# Error monitoring script
if grep -q "ERROR" /var/log/myapp.log; then
    echo "Errors detected at $(date)" > /tmp/error-report.txt
    tail -n 100 /var/log/myapp.log >> /tmp/error-report.txt
    
    URL=$(cat /tmp/error-report.txt | curl -s -X POST https://copyandpaste.at/api/log --data-binary @-)
    
    # Send alert with paste URL
    echo "Error log: $URL" | mail -s "Application Errors" admin@example.com
fi

CI/CD Integration

# GitHub Actions example
- name: Share build logs on failure
  if: failure()
  run: |
    cat build.log | curl -X POST https://copyandpaste.at/api/log --data-binary @- > paste_url.txt
    echo "Build logs: $(cat paste_url.txt)" >> $GITHUB_STEP_SUMMARY

Questions or need help? The API is simple and reliable - just pipe your content and get a shareable URL back!